SignalK / signalk-server

An implementation of a Signal K central server for boats.
http://signalk.org
Apache License 2.0
308 stars 153 forks source link

Bacon Stream or Bus confusion #1140

Closed preeve9534 closed 4 years ago

preeve9534 commented 4 years ago

The SignalK documentation identifies two functions in the plugin API documented at https://github.com/SignalK/signalk-server/blob/master/SERVERPLUGINS.md:

app.streambundle.getSelfBus(path) Get a Bacon JS stream for vessels.self's Signal K path. path argument is optional. If it is not provided the returned stream produces values for all paths. Stream values are objects with structure

and

app.streambundle.getSelfStream(path) Get a Bacon JS stream for vessels.self's Signal K path. path argument is optional. If it is not provided the returned stream produces values for all paths. This is similar to app.streambundle.getSelfBus(path), but the stream values are the value properties from incoming deltas.

I note that the choice of "bus" and "stream" language here is a tad problematic because BaconJS uses the terms Bus and EventStream for two of its core data types. The problem is that the SignalK documentation states that app.streambundle.getSelfStream() returns a Bacon JS stream (implying an EventStream (or not?), but it seems to return a BaconJS Bus.

var stream = app.streambundle.getSelfStream(path);
console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " + stream);

Results in a log entry:

Sep 27 16:45:18 helm signalk-server[5207]: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Bacon.Bus()

I'm confused. Others might be too.

P

tkurki commented 4 years ago

https://baconjs.github.io/api.html#bus

Bus is an EventStream that allows you to push values into the stream. It also allows plugging other streams into the Bus.

The choice of Stream and Bus in naming here was more ad hoc than result of thinking things through - sorry about any confusion.

Btw naming one of them Bus is not an invitation to start pushing arbitrary data into it.

If you come up with a concrete proposal on how the documentation can be improved feel free to submit a Pull Request. I am too far into it to be able to see what changes would be helpful. This is the very first I hear that this particular thing is confusing. From a plugin's perspective there is no practical difference between a Bus and an EventStream.

preeve9534 commented 4 years ago

I'll have a think about it Teppo. No difference except the invitation to push . ... 🤔

P

On Sun, 27 Sep 2020, 18:07 Teppo Kurki, notifications@github.com wrote:

https://baconjs.github.io/api.html#bus

Bus is an EventStream that allows you to push values into the stream. It also allows plugging other streams into the Bus.

The choice of Stream and Bus in naming here was more ad hoc than result of thinking things through - sorry about any confusion.

Btw naming one of them Bus is not an invitation to start pushing arbitrary data into it.

If you come up with a concrete proposal on how the documentation can be improved feel free to submit a Pull Request. I am too far into it to be able to see what changes would be helpful. This is the very first I hear that this particular thing is confusing. From a plugin's perspective there is no practical difference between a Bus and an EventStream.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/SignalK/signalk-server/issues/1140#issuecomment-699654164, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE2BPMICOFTW72B4JB5YJKLSH5PLHANCNFSM4R3THAGA .