-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat: add useWebLocks (Web Locks API) and useLeaderElection #4574
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
base: main
Are you sure you want to change the base?
Conversation
d3765a2
to
5cdead8
Compare
a957f0e
to
7b6789d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i like it.
… tabs elect a leader among them)
5a4c544
to
91a3f04
Compare
I just pushed a new version but also converted this PR to a draft since I am not finished polishing it ( Thank you, @OrbisK, for very valuable pointers and code reviews so far! |
```ts | ||
import { useLeaderElection } from '@vueuse/core' | ||
|
||
const { asLeader, isElected, isSupported } = useLeaderElection({ name: 'lock-name' }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const { asLeader, isElected, isSupported } = useLeaderElection({ name: 'lock-name' }) | |
const { asLeader, isLeader, isSupported } = useLeaderElection({ name: 'lock-name' }) |
Before submitting the PR, please make sure you do the following
fixes #123
).Description
Introduces a reactive version of the Web Locks API that automatically releases the locks when the current scope gets disposed.
Use this new composable for another new composable
useLeaderElection
with which one can elect one of possible many tabs to do work. This can be used to e.g. refresh a session only in one tab.