Skip to content
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

Add Signal#getAndDiscreteUpdates #3125

Merged

Conversation

armanbilge
Copy link
Member

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 a Stream 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 by discrete.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 default uncons1 implementation.

Furthermore, get and discrete can both be derived from getAndDiscreteUpdates much more easily than the other way around.

@mpilquist
Copy link
Member

Need conflict mixup

@mpilquist mpilquist merged commit ce061a5 into typelevel:main Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants