-
Notifications
You must be signed in to change notification settings - Fork 97
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
[question] Differences in behaviour of flatten
ed stream
#233
Comments
Yes of course. The logic is that the differences in behaviour came from changes. You subscribe only the default from a property. First change is the "end". |
Not exactly; the |
I thought than |
It isn't. Kefir.constant([1, 2, 3])
.flatten()
.spy()
.log('observer'); Output:
The spy logger don't add It's a strange example and I should thought about my use of To init a stream you can: Kefir.later(0, [1, 2, 3])
.flatten() |
@jensklose this is what I'm asking about. Why it works like this? I don't think example using It is counter-intuitive as for library user, this what I'm trying to say. I want to know, is it a, let say, "side-effect" of library design (and so, ok, we should live with this, at least for now), or all this is intentional (and then what's the real practical purpose) ? |
First of all, it's intentional. And yes for a library user it is important to know the difference of streams and properties. Your mock should work with
What's the real practical purpose?Properties are setting observable values. You could pull at any time (synchronously) a library compatible current value. |
Hi!
It found yet another interesting case with
.constant
method (my favourite one 😄), which I can't explain myself, so I need a help.A simple snippet:
Output is pretty predictable:
Now let's do a little change:
Output:
It looks quite confusing. Of course, there is a difference –
constant
creates a property, whilesequentially
creates a stream. But I can't understand how does it matter in this case. From naive point of view, these two snippets are logically equivalent: they both emit one array value and then end; and in both cases array is then synchronously transformed into series of separate values.But in case with
constant
, it all looks like we're still dealing with a single value in the entire chain – note that final sum is not emitted. Even more, if we add.changes()
call after.flatten()
, then logger only outputs<end>
– just like if we've skipped the current value of property. Despite doc says thatflatten
always creates a stream, and so, if I understand correctly,.changes
should do effectively nothing here.Is it expected behaviour? And if yes, what logic is behind it?
The text was updated successfully, but these errors were encountered: