Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The motivation for this comes from Calico, where we want to get the current value of a
Signal
for immediate rendering, and also a handle to aStream
of discrete updates, that we can subscribe to at some later point (typically after rendering) (or not at all), without missing any updates.FWIW I did try the "hack" of
get
followed bydiscrete.drop(1)
, and this ended up breaking in some situations.I also tried inlining the default implementation here in Calico, but there is a noticeable performance difference (where by "noticeable", I mean visible UX latency in a webapp).
Suffice to say, the win comes from the fact that each
Signal
can override this with something more efficient (basically just a.get
) than the defaultuncons1
implementation.Furthermore,
get
anddiscrete
can both be derived fromgetAndDiscreteUpdates
much more easily than the other way around.