-
Notifications
You must be signed in to change notification settings - Fork 80
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
Function-based discovery API alternative #864
Conversation
@@ -1,6 +1,6 @@ | |||
{ | |||
"compilerOptions": { | |||
"target": "es6", | |||
"target": "es2018", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No real review yet.. just since I stumbled over this change
I am not sure but I think we used to have issues with the browser-bundle when increasing the target version.. I might be wrong though...
467b048
to
c0178ea
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #864 +/- ##
==========================================
- Coverage 76.67% 74.72% -1.96%
==========================================
Files 80 80
Lines 16625 16806 +181
Branches 1603 1624 +21
==========================================
- Hits 12748 12558 -190
- Misses 3847 4201 +354
- Partials 30 47 +17 ☔ View full report in Codecov by Sentry. |
I'll convert this PR to a draft for now as it is still WIP (or might even be closed in the end). |
I tried to align this PR a bit more to the current state of the spec, but it seems to me as if we would need to update the typescript-definitions for that to really work 🤔 |
In general, I think it should be possible to replace the |
This commit should probably be dropped
08c064e
to
495b857
Compare
Hmm, I think in order to make things a bit cleaner, I will close this PR and replace it with another one that only implements the |
After today's discussion in the WoT Scripting API call, I decided to provide an alternative PR to #773 that uses a more "functional" approach to discovery (as proposed by @relu91 in w3c/wot-scripting-api#222), modelling each discovery method as its own method of an internal
ThingDiscovery
object.Since there was some discussion regarding the return type of the
direct
method, I provided two alternatives, one of which returns aThingDescription
object while the other one returns an iterableAsyncGenerator
(which is a slightly different concept to anAsyncIterator
, more similar to Dart Streams with a more intuitive API in my opinion).As I mentioned in the call, a generator/iterator-based return type would also make it possible to support discovery from a multicast URL with the
direct
method, simple yielding multiple TDs if the underlying platform should receive multiple responses. However, this might only be relevant for CoAP over UDP, so this might not be the strongest argument for a generator-based return type. Still, I think it might be worth considering.In general, I think this looks promising, and I am looking forward to your feedback :)
Edit: Thinking about it, the
AsyncGenerator
should rather still be anAsyncIterator
in order to be able to cancel the discovery process.