xstream icon indicating copy to clipboard operation
xstream copied to clipboard

Improving Producer documentation

Open mightyiam opened this issue 8 years ago • 2 comments

In the readme, in the example under Producer, the start property is a function that takes listener.

Now, this is a bit confusing, because I thought that this listener is actually the listener that I give to .addListener. But turns out that it is not. It is some internal stream...

So, I've found this documentation confusing. I would like to improve it.

And this entire paragraph, I think it is too advanced or too abstract or lacking context in order to be understood and useful to most users:

Streams are also Listeners (actually they are "InternalListeners", not Listeners, but that's a detail you can ignore), so you can theoretically give a Stream as the listener in producer.start(streamAsListener). Then, essentially the Producer is now generating events that will be broadcast on the Stream. Nice, huh? Now a bunch of listeners can be attached to the Stream and they can all get those events originally coming from the Producer. That's why xs.create(producer) receives a Producer to be the heart of a new Stream. Check this out:

So, I'm going to try to revise this. If you have any tips or emphases, please let me know.

mightyiam avatar May 08 '17 07:05 mightyiam

What I find confusing in the quoted paragraph as well as in

Once you call start with a listener, the Producer will start generating events and it will send those to the listener. When you call stop(), the Producer should quit doing its own thing.

is that as far as my experience goes, as an average or advanced user you never call start() and stop(). You provide those callsbacks and the stream implementation calls them depending on the listener count.

webmaster128 avatar Jan 11 '19 22:01 webmaster128

Yes I agree it could be better phrased.

staltz avatar Jan 14 '19 10:01 staltz