-
Notifications
You must be signed in to change notification settings - Fork 28
Use Observables instead of callbacks? #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Use case: return an
For example: let subscription = asyncOperation(parameters).subscribe({
next(val) { console.log("Received next result: " + val); },
error(err) { console.log("Received an error: " + err); },
complete() { console.log("Operation complete"); }
});
// ...
subscription.cancel(); Alternatively, we could say let subscription = asyncOperation(parameters)
.on("next", val => { console.log("Received next result: " + val); })
.on("error", function(err) { console.log("Received an error: " + err); })
.on("complete", () => { console.log("Operation complete"); })
; Or, let subscription = asyncOperation(parameters)
.next(val => { console.log("Received next result: " + val); })
.complete( () => { console.log("Operation complete"); })
.catch(err => { console.log("Received an error: " + err); });
; |
This would be used mainly with discovery operations. |
We could do a polyfill for the above options, or continue to use callbacks for discovery, but without the ability to cancel discovery, or to know when discovery has ended (when these are supported by the underlying protocols). |
I am +1 on observables for discovery (and maybe also subscription). I would stick to the current ECMA discussion. I don't know if there is a polyfill already defined, it seems Angular2 used RxJS, which could be an option. |
Conclusion on call 27-03-2017 is to go for a subset of current ECMA discussion, risking a breakage but betting on promising candidate. |
Link to proposal: https://github.com/tc39/proposal-observable |
Leaving this open for further feedback. |
Discussion in the meeting on Aug 21 did not reveal any major issue but decided to leave this open for now. |
I think with the latest updates we can close this issue, correct? |
Addressed by #86. |
As described here and agreed on the face to face meeting,
This issue is for tracking and discussing the WoT use case for Observables.
The text was updated successfully, but these errors were encountered: