5 ms·
Tbf, I would gladly take mutability or impureness over unnecessarily complicated approach. One example of it is the suspense api in react. Suspense uses a promi
by searchableguy 6y ago
Tbf, I would gladly take mutability or impureness over unnecessarily complicated approach. One example of it is the suspense api in react. Suspense uses a promise throw approach opposed to generators. Your code throws a promise and suspense catches it to render fallback until it is resolved.
You end up with few ugly situations. First, I hate that I have to wrap my components (what if you want different fallback for different components? You end up with many wraps), how my UI will render is not isolated anymore. I often end up returning loading view from the components as we as well using it as a fallback for suspense. It just feels wrong. I lack control.
- holler 6y agofor things like loading state with ember we use a library called ember-concurrency that uses the generator approach. It's very nice! Example you can create some "task" (promise-like), then in a template you have automatic access to it's state so e.g. ``` {{#if this.fetchStoriesTask.isRunning}} loading... {{else}} <span>Loaded 10 Stories</span> {{/if}} ``` https://github.com/machty/ember-concurrency https://github.com/machty/ember-concurrency
- mnutt 6y agoember-concurrency is probably at the top of the list for things I miss most when writing javascript outside of ember.