-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
RFC: Rename signal.changes to... signal.updates? #132
Comments
When I started reading the post I immediately wanted to ask if there is a way we could have an actual It's easy to implement in the "userland": EventStream.merge(
EventStream.unit().sample(signal),
signal.changes
) but maybe it could be implemented more efficiently. I don't have a use-case at hand right now (I'll look for it) - for the signal-to-stream transformation - but I know I end up doing this every now and then :) |
Yes, good point, that's another reason not to use So far I have resisted adding a real However, in recent versions of Airstream we have a special mechanism for re-starting streams that depend on signal, e.g. if you restarted We could, I guess, implement a Would that be the desirable behaviour for you? Also, at a high level, what's your most common use cases for wanting .toStream? I was hoping that with signals behaving more like streams without the But that still leaves us with the other issue: the signal's current value is not an event that is pushed – it is not fired in any transaction – it's effectively a value that is pulled – and by design that happens outside of any transaction, as transactions are not really needed when pulling. So, But to be honest, I'm not sure if the transaction concern is real or just theoretical. What kind of observable graph / use case would see that problem? The problem is only for the initial value, not subsequent events. It would need to be something non-trivial to cause a problem I think. And, keep in mind that So, |
I would also love this feature to exist. Currently what I've done locally is extension [T](signal: Signal[T])
inline def toStream: EventStream[T] = new StreamFromSignal(parent = signal, changesOnly = false)
|
@ivan-klass This may not work in all edge cases. See #124 |
signal.changes
is a stream that emits all events / updates insignal
, EXCLUDING its current value ("current" at the moment of activating the subscription).The name
.changes
implies that there is some deduplication going on under the hood, and in fact that was the case pre-15.0.0, when signals had built-in==
checks. But such deduplication is not there anymore, so the name stopped serving us well.I suggest keeping
.changes
available but@deprecated
, since there are a bunch of materials online referencing it, and creating a new method called.updates
that does the same thing. Feel free to suggest alternative names. Note that the name should work for several methods:signal.changes
,signal.changes(_.distinct)
,signal.composeChanges(_.distinct)
.Another potential naming option is
.toStream
, but this name does not reflect the fact that the initial value will be missing from the stream. That will surely surprise new users.BTW If anyone wants to suggest a change in how the
changes
API should work, now would be a good time.The text was updated successfully, but these errors were encountered: