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

Is there any way for leader election? #2

Open
maktouch opened this issue Feb 13, 2017 · 3 comments
Open

Is there any way for leader election? #2

maktouch opened this issue Feb 13, 2017 · 3 comments
Assignees
Milestone

Comments

@maktouch
Copy link

Hi,

I'd like to know if you have any plans to implement leader/master election?

It would be useful for cases to prevent multiple tabs from polling the server (just the master would poll the server and sync to the other tabs)

Cheers

@cchamberlain
Copy link
Member

Thanks @maktouch for opening. This sounds like an interesting feature. The biggest use case I've had for localsync is usage in (redux-idle-monitor)[https://github.com/noderaider/redux-idle-monitor] which is strictly client-to-client notification of user activity. I'd love to hear of different use cases as this will help me to add features.

This type of feature could definitely complicate the API so it needs to be well thought out and optional. Seems like the best way for this to work would maybe be to have it keep track of the latest active tab and allow functions to only be scoped to the most recent active one (and default would remain unscoped). I could essentially drop some of the core (non-redux) logic from redux-idle-monitor down into localsync.

Would appreciate your thoughts on this, if you have any additional ideas feel free to toss them in. I'm very busy this week, may have some time to implement in the next month. Would be open to a PR on this as well.

@maktouch
Copy link
Author

Hey @cchamberlain

Thanks for your quick answer.

We have an app that needs to poll for the server every X minutes. To prevent rate limiting, if the user has multiple tabs open, only one of the tab should be polling.

We're split between using this or https://github.com/tejacques/crosstab (crosstab has that feature, but its code seems a little old and it seems unmaintained).

Cheers

@cchamberlain
Copy link
Member

@maktouch - thanks for shooting over the link to crosstab for reference. I think it's worthwhile to add this feature. I should be able to get to it in the next two weeks when my schedule frees up. Thinking through some of the implementation details in the meantime. I'm still thinking it makes sense to have the master logic be available on all tabs but only run on the tab that has the most latest user activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants