You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is nothing really tricky about using Microstates with Ember Concurrency, but we do want to make this clearer with a good example. For all intents and purposes, Microstates behave like Computed Properties. You can write values to them and the result will be computed synchronously when the value is read. Microstates also debounce no-op write operations.
To use Microstates with EC, you would probably want to define the state on the component rather than in the template. It's possible to send a microstate as an argument to the task, so that could be an option for microstates defined in the template.
importComponentfrom'@ember/microstates';import{state}from'@microstates/ember';import{task}from'ember-concurrency';importfetchfrom'ember-network';classPerson{name=String;age=String;getsummary(){return`${this.name.state} is ${this.age.state}`;}}exportdefaultComponent.extend({person: state(Person),fetchPerson: task(function*(){letresponse=yieldfetch('person');letperson=yieldresponse.json();this.get('person').set(person);returnthis.get('person.summary');})});
The text was updated successfully, but these errors were encountered:
There is nothing really tricky about using Microstates with Ember Concurrency, but we do want to make this clearer with a good example. For all intents and purposes, Microstates behave like Computed Properties. You can write values to them and the result will be computed synchronously when the value is read. Microstates also debounce no-op write operations.
To use Microstates with EC, you would probably want to define the state on the component rather than in the template. It's possible to send a microstate as an argument to the task, so that could be an option for microstates defined in the template.
The text was updated successfully, but these errors were encountered: