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

Reimplement SubscriptionRef in Terms of ZHub #4916

Merged
merged 1 commit into from Apr 9, 2021

Conversation

adamgfraser
Copy link
Contributor

One issue with the current implementation of SubscriptionRef is that since it is backed by a Queue, if more than one subscriber is observing changes to the Ref each subscriber will miss changes, since each time a value is taken from the queue by one subscriber it is no longer available to other subscribers. We can address this by backing SubscriptionRef with a Hub . This way each subscriber can receive the current value of the Ref and all changes after they have subscribed.

This allows SubscriptionRef to function much like a Var in functional reactive programming frameworks, where the SubscriptionRef represents some state that can be changes and multiple processes can subscribe to take actions in response to any changes in that state.

Copy link
Member

@iravid iravid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome.

@adamgfraser adamgfraser merged commit 89d921d into zio:master Apr 9, 2021
@adamgfraser adamgfraser deleted the subscriptionref branch April 9, 2021 12:08
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.

None yet

2 participants