![]() Next, let's learn about the awesome ES6 language feature that makes all of this possible: the generator function. We've now seen how Ember Concurrency helps us avoid bugs while writing clean, easy-to-read code. Our programming model is aligned with our mental model, which makes it much easier to manage concurrent activities in our application. This is a shining example of the benefits of structured concurrency: we're able to write long-running code that is naturally bounded by its parent. When we toggle the button and the component is torn down, the task is canceled, and the last line simply never executes. This is because Ember Concurrency pauses at the yielded code, and only continues if the component is still on the page. The component works just like before, but this time if we hide the component before the request finishes, we don't see the exception thrown. Here's our current implementation: // components/autocomplete-searchbox.js import Ember from 'ember' Įmber.$.getJSON( '/query', ) Īnd we've actually just solved our bug! Let's see it in action. Important: if you render the selected item here (rather than in a separate component, as shown later in this post), then the keys within the options must match the keys within the selected item.In this video, we'll look at a naive implementation of an autocomplete searchbox, and use an Ember Concurrency Task to improve it. ![]() In this example, if I select “Default Filter” as the selected filter, that object will be bound to |filter|.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |