diff options
author | dan <dan.abramov@gmail.com> | 2024-08-06 01:30:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-06 01:30:52 +0100 |
commit | 686d5ebb535710dd8c96aa694b4cd1f7913ff3fa (patch) | |
tree | 35ca7e7646d455468c97520b8cb972e8555fc3f2 /src/state/invites.tsx | |
parent | 966f6c511fff510fc011aa5c426c6b7eaf4f21ac (diff) | |
download | voidsky-686d5ebb535710dd8c96aa694b4cd1f7913ff3fa.tar.zst |
[Persisted] Make broadcast subscriptions granular by key (#4874)
* Add fast path for guaranteed noop updates * Change persisted.onUpdate() API to take a key * Implement granular broadcast listeners
Diffstat (limited to 'src/state/invites.tsx')
-rw-r--r-- | src/state/invites.tsx | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/state/invites.tsx b/src/state/invites.tsx index 6a0d1b590..0d40caf25 100644 --- a/src/state/invites.tsx +++ b/src/state/invites.tsx @@ -1,4 +1,5 @@ import React from 'react' + import * as persisted from '#/state/persisted' type StateContext = persisted.Schema['invites'] @@ -35,8 +36,8 @@ export function Provider({children}: React.PropsWithChildren<{}>) { ) React.useEffect(() => { - return persisted.onUpdate(() => { - setState(persisted.get('invites')) + return persisted.onUpdate('invites', nextInvites => { + setState(nextInvites) }) }, [setState]) |