Robert Elliot Robert Elliot - 1 year ago 82
Javascript Question

Control the order of ember promise resolution?

I've been following the tutorial, using ember 2.9.1, node 6.9.1, chrome 53.0.2785.143 and OS/X 10.11.6.

When I create the component described here:

I end up with a race condition. If I enter the character p into the input and very rapidly hit backspace, I end up with the models filtered by the character p but no input in the text field.

Some console logging suggests this is happening because the second promise (which returns all the models, since the input is empty) is resolving first, and the first promise (returning the filtered models) resolves second.

Is there anything that can be done about this?

Answer Source

For concurrency purposes, there is an addon called: ember-concurrency. You can use it for all your async operations.

Also ember-power-select uses this addon. It is a powerful, auto-complete select component. I can suggest you to use it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download