Skip to content

Commit

Permalink
README: more options documented.
Browse files Browse the repository at this point in the history
  • Loading branch information
molefrog authored May 22, 2023
1 parent 8ee5426 commit e15d964
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,21 @@
*/

// simple usage
import { useLeader } from "use-leader"
const { isLeader } = useLeader() // true/false

// alias, provides boolean value only
import { useIsLeader } from "use-leader"
const isLeader = useIsLeader() // true/false

// additional state
const {
id, // id of the current node (tab)
leaderId, // id of the elected leader
ref // reference to election instance, can be used for imperative control
// over the state of the node e.g. `ref.lead()` - force become a leader
} = useLeader()

// each node has a unique identifier, when the leader is elected, every node holds
// the leading id. these ids are randomly generated... so why would you want
// to override it?
Expand Down

0 comments on commit e15d964

Please sign in to comment.