Subscribing from server plugin

21 views
Skip to first unread message

Владимир Калачихин

unread,
Apr 14, 2022, 8:07:55 AM4/14/22
to Signal K
What way is more correct for subscribe to deltas in server plugin:
use app.subscriptionmanager.subscribe(...
or use app.streambundle.getSelfStream(...
?

Teppo Kurki

unread,
Apr 14, 2022, 9:26:03 AM4/14/22
to signalk
Depends.

streambundle gives you a BaconJs stream, that has a bunch of handy functionality already built in. For example combining several SK values to output data in another format, like NMEA0183: you have an easy method to say that whenever a, b or c change combine them in a certain way and do output only once per second. Then again the reactive functional paradigm in BaconJs can be hard to understand if you are very imperative programming oriented.

Subscriptions have no "bonus functionality". Whatever you do with the data is totally your own code. 

One clear difference is that subscriptions are available on the client side also. So if you might want to run the same logic in browser UI for example you'd want to use subscriptions.

  

Владимир Калачихин

unread,
Apr 14, 2022, 9:57:14 AM4/14/22
to Signal K
Thanks.
Maybe the BaconJs is cool, but it takes a big lot to learn to take advantage of it. Mostly it's inadvisable. Very imperative programming is enougth.

четверг, 14 апреля 2022 г. в 16:26:03 UTC+3, Teppo Kurki:

Владимир Калачихин

unread,
Apr 18, 2022, 4:27:54 AM4/18/22
to Signal K
The main difference is that there is the only one delta handler for all subscribes in case of app.subscriptionmanager.

четверг, 14 апреля 2022 г. в 16:57:14 UTC+3, Владимир Калачихин:

Teppo Kurki

unread,
Apr 18, 2022, 11:59:49 AM4/18/22
to signalk
On Mon, Apr 18, 2022 at 11:27 AM Владимир Калачихин <v.kala...@gmail.com> wrote:
The main difference is that there is the only one delta handler for all subscribes in case of app.subscriptionmanager.

No, you can call app.subscriptionmanager.subscribe multiple times and set up multiple separate subscriptions with their respective delta handlers.
 
--
You received this message because you are subscribed to the Google Groups "Signal K" group.
To unsubscribe from this group and stop receiving emails from it, send an email to signalk+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/signalk/76825c22-2841-45c5-84d0-530d81965bc5n%40googlegroups.com.

Владимир Калачихин

unread,
Apr 19, 2022, 4:31:23 PM4/19/22
to Signal K


понедельник, 18 апреля 2022 г. в 18:59:49 UTC+3, Teppo Kurki:
On Mon, Apr 18, 2022 at 11:27 AM Владимир Калачихин <v.kala...@gmail.com> wrote:
The main difference is that there is the only one delta handler for all subscribes in case of app.subscriptionmanager.

No, you can call app.subscriptionmanager.subscribe multiple times and set up multiple separate subscriptions with their respective delta handlers.

Yes, it works, thanks.
This should be included in the documentation, because it's not obvious.
Reply all
Reply to author
Forward
0 new messages