Bikeshed: Do Promise-ifying methods need to be on Observable instances?
The other option would be to add these methods to be static methods on Observable or even Promise.
Observable.every(source);
One justification here is that methods that return Promise instead of Observable shouldn't be as easily chainable in the same way.
One justification here is that methods that return Promise instead of Observable shouldn't be as easily chainable in the same way.
I'm not sure I understand the reasoning behind this sentence. Why shouldn't they be as easily chainable?
+1 to @tabatkins's comment. I'm not sure I understand what's undesirable about:
observable
.every(() => { ... })
.then(() => { ... })
.then(() => { ... })
?
One of the things that was discussed at TPAC was the issues around doing this:
observable.find(() => true).then(([e]) => {
e.stopPropagation(); // OOPS! Too late because promise scheduling :(
});
It's probably better to have all of these return an Observable.
- It's more consistent.
- It models the EventTargets we're building this for better.
The forEach function can still return a Promise, but the handler it has can be synchronously invoked.