-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Initial Recoil Sync implementation #1225
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
facebook-github-bot
added
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
fb-exported
labels
Sep 17, 2021
This pull request was exported from Phabricator. Differential Revision: D30467990 |
This pull request was exported from Phabricator. Differential Revision: D30467990 |
drarmstr
added a commit
to drarmstr/Recoil
that referenced
this pull request
Sep 17, 2021
Summary: Pull Request resolved: facebookexperimental#1225 Initial implementation of `recoil-sync` with `useRecoilSync()` hook and `syncEffect()` atom effect. This just includes the basic functionality of registering atoms and reading/writing from storage. Lots more diffs to come to complete the full support. Current RFC API (*in flux based on ongoing feedback*): ``` type AtomDiff = Map<ItemKey, ?Loadable<mixed>>; // null entry means reset useRecoilSync({ syncKey?: SyncKey, // key to match with syncEffect() write?: ({diff: ItemDiff, items: ItemSnapshot}) => void, read?: ItemKey => ?Loadable<mixed>, listen?: (AtomDiff => void) => (() => void), }) => void; ``` ``` function syncEffect<T>(params: { syncKey?: SyncKey, // key to match with useRecoilSync() key?: ItemKey, // defaults to Atom key restore: mixed => ?Loadable<T>, // For advanced use-cases read?: ({read: ItemKey => ?Loadable<mixed>}) => Loadable<mixed>, write?: (Loadable<T>, {read: ItemKey => ?Loadable<mixed>}) => ItemDiff, }): AtomEffect<T> ``` Reviewed By: csantos42 Differential Revision: D30467990 fbshipit-source-id: f496920d925f3e652738d2f4e0c06072b0e3e8e6
drarmstr
force-pushed
the
export-D30467990
branch
from
September 17, 2021 23:18
d8c5f1f
to
69ddb66
Compare
…ntal#1205) Summary: Pull Request resolved: facebookexperimental#1205 Add the ability for atom effects to get the value of other atoms. It can either get the values at the time of the atom initialization when the effect executes or it can get the values later during some async callback from the effect. ``` export type AtomEffect<T> = ({ ... // Accessors to read other atoms/selectors getPromise: <T>(RecoilValue<T>) => Promise<T>, getLoadable: <T>(RecoilValue<T>) => Loadable<T>, }) => void | (() => void); ``` It is important to note that getting other atom values does not establish any subscription to re-evaluate anything if the upstream atoms may change. Alternative APIs to consider was exposing a transaction. But, we don't want to write to other atoms during initialization and it would be a stretch to create a read-only transaction type, especially as transactions don't currently have a return value. Another alternative would be offering to get a `Snapshot`. This would be a convenient API and nicely consistent and makes it very explicit that no subscription is established. However, retention for garbage collection is a concern. We could release the `Snapshot` after initialization, which would be straight-forward, but there isn't a clear please to automatically release or explicitly retain for async obtained snapshots. This proposed API mirrors the Snapshot interface for getting values to try to maximize consistency. Example use-cases for this functionality: * Use of other atom values to compute initial value. e.g. another atom may store some query mode to use. * Effects for data-loggers for multiple atoms * "Persist on set" - The ability to use an atom effect to initialize an atom based on other atom values and have the initial value persisted based on observing by other atom effects or the recoil sync library. This is in contrast to using a default selector for an atom for a dynamic default based on other atoms. That creates a wrapper selector, remains dynamic until set, and doesn't cause the atom to persist until it is explicitly set. Differential Revision: D30691374 fbshipit-source-id: d345765b52e419c60f8b7f564586673b3ffbc5e5
Summary: Pull Request resolved: facebookexperimental#1225 Initial implementation of `recoil-sync` with `useRecoilSync()` hook and `syncEffect()` atom effect. This just includes the basic functionality of registering atoms and reading/writing from storage. Lots more diffs to come to complete the full support. Current RFC API (*in flux based on ongoing feedback*): ``` type AtomDiff = Map<ItemKey, ?Loadable<mixed>>; // null entry means reset useRecoilSync({ syncKey?: SyncKey, // key to match with syncEffect() write?: ({diff: ItemDiff, items: ItemSnapshot}) => void, read?: ItemKey => ?Loadable<mixed>, listen?: (AtomDiff => void) => (() => void), }) => void; ``` ``` function syncEffect<T>(params: { syncKey?: SyncKey, // key to match with useRecoilSync() key?: ItemKey, // defaults to Atom key restore: mixed => ?Loadable<T>, // For advanced use-cases read?: ({read: ItemKey => ?Loadable<mixed>}) => Loadable<mixed>, write?: (Loadable<T>, {read: ItemKey => ?Loadable<mixed>}) => ItemDiff, }): AtomEffect<T> ``` Reviewed By: csantos42 Differential Revision: D30467990 fbshipit-source-id: 698c5c7bd9d85ba2cc7473cdc8c1512b875890a8
drarmstr
force-pushed
the
export-D30467990
branch
from
September 17, 2021 23:42
69ddb66
to
8f77927
Compare
This pull request was exported from Phabricator. Differential Revision: D30467990 |
drarmstr
added a commit
to drarmstr/Recoil
that referenced
this pull request
Sep 18, 2021
Summary: Pull Request resolved: facebookexperimental#1225 Initial implementation of `recoil-sync` with `useRecoilSync()` hook and `syncEffect()` atom effect. This just includes the basic functionality of registering atoms and reading/writing from storage. Lots more diffs to come to complete the full support. Current RFC API (*in flux based on ongoing feedback*): ``` type AtomDiff = Map<ItemKey, ?Loadable<mixed>>; // null entry means reset useRecoilSync({ syncKey?: SyncKey, // key to match with syncEffect() write?: ({diff: ItemDiff, items: ItemSnapshot}) => void, read?: ItemKey => ?Loadable<mixed>, listen?: (AtomDiff => void) => (() => void), }) => void; ``` ``` function syncEffect<T>(params: { syncKey?: SyncKey, // key to match with useRecoilSync() key?: ItemKey, // defaults to Atom key restore: mixed => ?Loadable<T>, // For advanced use-cases read?: ({read: ItemKey => ?Loadable<mixed>}) => Loadable<mixed>, write?: (Loadable<T>, {read: ItemKey => ?Loadable<mixed>}) => ItemDiff, }): AtomEffect<T> ``` Differential Revision: D30467990 fbshipit-source-id: 28d46e1781764c43dc93ed806b2bb600656e0bd7
drarmstr
added a commit
to drarmstr/Recoil
that referenced
this pull request
Sep 18, 2021
Summary: Pull Request resolved: facebookexperimental#1225 Initial implementation of `recoil-sync` with `useRecoilSync()` hook and `syncEffect()` atom effect. This just includes the basic functionality of registering atoms and reading/writing from storage. Lots more diffs to come to complete the full support. Current RFC API (*in flux based on ongoing feedback*): ``` type AtomDiff = Map<ItemKey, ?Loadable<mixed>>; // null entry means reset useRecoilSync({ syncKey?: SyncKey, // key to match with syncEffect() write?: ({diff: ItemDiff, items: ItemSnapshot}) => void, read?: ItemKey => ?Loadable<mixed>, listen?: (AtomDiff => void) => (() => void), }) => void; ``` ``` function syncEffect<T>(params: { syncKey?: SyncKey, // key to match with useRecoilSync() key?: ItemKey, // defaults to Atom key restore: mixed => ?Loadable<T>, // For advanced use-cases read?: ({read: ItemKey => ?Loadable<mixed>}) => Loadable<mixed>, write?: (Loadable<T>, {read: ItemKey => ?Loadable<mixed>}) => ItemDiff, }): AtomEffect<T> ``` Differential Revision: D30467990 fbshipit-source-id: ca7063ff1169a96b8158cef91d7516349f61a25d
drarmstr
added a commit
to drarmstr/Recoil
that referenced
this pull request
Sep 18, 2021
Summary: Pull Request resolved: facebookexperimental#1225 Initial implementation of `recoil-sync` with `useRecoilSync()` hook and `syncEffect()` atom effect. This just includes the basic functionality of registering atoms and reading/writing from storage. Lots more diffs to come to complete the full support. Current RFC API (*in flux based on ongoing feedback*): ``` type AtomDiff = Map<ItemKey, ?Loadable<mixed>>; // null entry means reset useRecoilSync({ syncKey?: SyncKey, // key to match with syncEffect() write?: ({diff: ItemDiff, items: ItemSnapshot}) => void, read?: ItemKey => ?Loadable<mixed>, listen?: (AtomDiff => void) => (() => void), }) => void; ``` ``` function syncEffect<T>(params: { syncKey?: SyncKey, // key to match with useRecoilSync() key?: ItemKey, // defaults to Atom key restore: mixed => ?Loadable<T>, // For advanced use-cases read?: ({read: ItemKey => ?Loadable<mixed>}) => Loadable<mixed>, write?: (Loadable<T>, {read: ItemKey => ?Loadable<mixed>}) => ItemDiff, }): AtomEffect<T> ``` Differential Revision: D30467990 fbshipit-source-id: 9b5b3254c5968f696272c55e438985c943155d91
drarmstr
added a commit
to drarmstr/Recoil
that referenced
this pull request
Sep 18, 2021
Summary: Pull Request resolved: facebookexperimental#1225 Initial implementation of `recoil-sync` with `useRecoilSync()` hook and `syncEffect()` atom effect. This just includes the basic functionality of registering atoms and reading/writing from storage. Lots more diffs to come to complete the full support. Current RFC API (*in flux based on ongoing feedback*): ``` type AtomDiff = Map<ItemKey, ?Loadable<mixed>>; // null entry means reset useRecoilSync({ syncKey?: SyncKey, // key to match with syncEffect() write?: ({diff: ItemDiff, items: ItemSnapshot}) => void, read?: ItemKey => ?Loadable<mixed>, listen?: (AtomDiff => void) => (() => void), }) => void; ``` ``` function syncEffect<T>(params: { syncKey?: SyncKey, // key to match with useRecoilSync() key?: ItemKey, // defaults to Atom key restore: mixed => ?Loadable<T>, // For advanced use-cases read?: ({read: ItemKey => ?Loadable<mixed>}) => Loadable<mixed>, write?: (Loadable<T>, {read: ItemKey => ?Loadable<mixed>}) => ItemDiff, }): AtomEffect<T> ``` Differential Revision: D30467990 fbshipit-source-id: f1eceb3384d8627ad3eaafc726e343a745f05c0f
drarmstr
added a commit
to drarmstr/Recoil
that referenced
this pull request
Sep 18, 2021
Summary: Pull Request resolved: facebookexperimental#1225 Initial implementation of `recoil-sync` with `useRecoilSync()` hook and `syncEffect()` atom effect. This just includes the basic functionality of registering atoms and reading/writing from storage. Lots more diffs to come to complete the full support. Current RFC API (*in flux based on ongoing feedback*): ``` type AtomDiff = Map<ItemKey, ?Loadable<mixed>>; // null entry means reset useRecoilSync({ syncKey?: SyncKey, // key to match with syncEffect() write?: ({diff: ItemDiff, items: ItemSnapshot}) => void, read?: ItemKey => ?Loadable<mixed>, listen?: (AtomDiff => void) => (() => void), }) => void; ``` ``` function syncEffect<T>(params: { syncKey?: SyncKey, // key to match with useRecoilSync() key?: ItemKey, // defaults to Atom key restore: mixed => ?Loadable<T>, // For advanced use-cases read?: ({read: ItemKey => ?Loadable<mixed>}) => Loadable<mixed>, write?: (Loadable<T>, {read: ItemKey => ?Loadable<mixed>}) => ItemDiff, }): AtomEffect<T> ``` Differential Revision: D30467990 fbshipit-source-id: a9d62a754b23ba7bc7b2a501abe2254cbd13f714
drarmstr
added a commit
to drarmstr/Recoil
that referenced
this pull request
Sep 18, 2021
Summary: Pull Request resolved: facebookexperimental#1225 Initial implementation of `recoil-sync` with `useRecoilSync()` hook and `syncEffect()` atom effect. This just includes the basic functionality of registering atoms and reading/writing from storage. Lots more diffs to come to complete the full support. Current RFC API (*in flux based on ongoing feedback*): ``` type AtomDiff = Map<ItemKey, ?Loadable<mixed>>; // null entry means reset useRecoilSync({ syncKey?: SyncKey, // key to match with syncEffect() write?: ({diff: ItemDiff, items: ItemSnapshot}) => void, read?: ItemKey => ?Loadable<mixed>, listen?: (AtomDiff => void) => (() => void), }) => void; ``` ``` function syncEffect<T>(params: { syncKey?: SyncKey, // key to match with useRecoilSync() key?: ItemKey, // defaults to Atom key restore: mixed => ?Loadable<T>, // For advanced use-cases read?: ({read: ItemKey => ?Loadable<mixed>}) => Loadable<mixed>, write?: (Loadable<T>, {read: ItemKey => ?Loadable<mixed>}) => ItemDiff, }): AtomEffect<T> ``` Differential Revision: D30467990 fbshipit-source-id: 53c7b68da433a19dc2c307584108fae630b8e6c9
drarmstr
added a commit
to drarmstr/Recoil
that referenced
this pull request
Sep 18, 2021
Summary: Pull Request resolved: facebookexperimental#1225 Initial implementation of `recoil-sync` with `useRecoilSync()` hook and `syncEffect()` atom effect. This just includes the basic functionality of registering atoms and reading/writing from storage. Lots more diffs to come to complete the full support. Current RFC API (*in flux based on ongoing feedback*): ``` type AtomDiff = Map<ItemKey, ?Loadable<mixed>>; // null entry means reset useRecoilSync({ syncKey?: SyncKey, // key to match with syncEffect() write?: ({diff: ItemDiff, items: ItemSnapshot}) => void, read?: ItemKey => ?Loadable<mixed>, listen?: (AtomDiff => void) => (() => void), }) => void; ``` ``` function syncEffect<T>(params: { syncKey?: SyncKey, // key to match with useRecoilSync() key?: ItemKey, // defaults to Atom key restore: mixed => ?Loadable<T>, // For advanced use-cases read?: ({read: ItemKey => ?Loadable<mixed>}) => Loadable<mixed>, write?: (Loadable<T>, {read: ItemKey => ?Loadable<mixed>}) => ItemDiff, }): AtomEffect<T> ``` Differential Revision: D30467990 fbshipit-source-id: a9fd47c7e5d86a0ca3712f44463df97f149dd3a7
drarmstr
added a commit
to drarmstr/Recoil
that referenced
this pull request
Sep 18, 2021
Summary: Pull Request resolved: facebookexperimental#1225 Initial implementation of `recoil-sync` with `useRecoilSync()` hook and `syncEffect()` atom effect. This just includes the basic functionality of registering atoms and reading/writing from storage. Lots more diffs to come to complete the full support. Current RFC API (*in flux based on ongoing feedback*): ``` type AtomDiff = Map<ItemKey, ?Loadable<mixed>>; // null entry means reset useRecoilSync({ syncKey?: SyncKey, // key to match with syncEffect() write?: ({diff: ItemDiff, items: ItemSnapshot}) => void, read?: ItemKey => ?Loadable<mixed>, listen?: (AtomDiff => void) => (() => void), }) => void; ``` ``` function syncEffect<T>(params: { syncKey?: SyncKey, // key to match with useRecoilSync() key?: ItemKey, // defaults to Atom key restore: mixed => ?Loadable<T>, // For advanced use-cases read?: ({read: ItemKey => ?Loadable<mixed>}) => Loadable<mixed>, write?: (Loadable<T>, {read: ItemKey => ?Loadable<mixed>}) => ItemDiff, }): AtomEffect<T> ``` Differential Revision: D30467990 fbshipit-source-id: 449c72b3dbaf5a7dc22a579e535db197f93d1a3f
drarmstr
added a commit
to drarmstr/Recoil
that referenced
this pull request
Sep 18, 2021
Summary: Pull Request resolved: facebookexperimental#1225 Initial implementation of `recoil-sync` with `useRecoilSync()` hook and `syncEffect()` atom effect. This just includes the basic functionality of registering atoms and reading/writing from storage. Lots more diffs to come to complete the full support. Current RFC API (*in flux based on ongoing feedback*): ``` type AtomDiff = Map<ItemKey, ?Loadable<mixed>>; // null entry means reset useRecoilSync({ syncKey?: SyncKey, // key to match with syncEffect() write?: ({diff: ItemDiff, items: ItemSnapshot}) => void, read?: ItemKey => ?Loadable<mixed>, listen?: (AtomDiff => void) => (() => void), }) => void; ``` ``` function syncEffect<T>(params: { syncKey?: SyncKey, // key to match with useRecoilSync() key?: ItemKey, // defaults to Atom key restore: mixed => ?Loadable<T>, // For advanced use-cases read?: ({read: ItemKey => ?Loadable<mixed>}) => Loadable<mixed>, write?: (Loadable<T>, {read: ItemKey => ?Loadable<mixed>}) => ItemDiff, }): AtomEffect<T> ``` Differential Revision: D30467990 fbshipit-source-id: fc87222b9371162a374993f6a241a72e9ce547c6
drarmstr
added a commit
to drarmstr/Recoil
that referenced
this pull request
Sep 18, 2021
Summary: Pull Request resolved: facebookexperimental#1225 Initial implementation of `recoil-sync` with `useRecoilSync()` hook and `syncEffect()` atom effect. This just includes the basic functionality of registering atoms and reading/writing from storage. Lots more diffs to come to complete the full support. Current RFC API (*in flux based on ongoing feedback*): ``` type AtomDiff = Map<ItemKey, ?Loadable<mixed>>; // null entry means reset useRecoilSync({ syncKey?: SyncKey, // key to match with syncEffect() write?: ({diff: ItemDiff, items: ItemSnapshot}) => void, read?: ItemKey => ?Loadable<mixed>, listen?: (AtomDiff => void) => (() => void), }) => void; ``` ``` function syncEffect<T>(params: { syncKey?: SyncKey, // key to match with useRecoilSync() key?: ItemKey, // defaults to Atom key restore: mixed => ?Loadable<T>, // For advanced use-cases read?: ({read: ItemKey => ?Loadable<mixed>}) => Loadable<mixed>, write?: (Loadable<T>, {read: ItemKey => ?Loadable<mixed>}) => ItemDiff, }): AtomEffect<T> ``` Differential Revision: D30467990 fbshipit-source-id: eef3a4c5086dbef75a954b4b8bbd81b33b2263a2
drarmstr
added a commit
to drarmstr/Recoil
that referenced
this pull request
Sep 18, 2021
Summary: Pull Request resolved: facebookexperimental#1225 Initial implementation of `recoil-sync` with `useRecoilSync()` hook and `syncEffect()` atom effect. This just includes the basic functionality of registering atoms and reading/writing from storage. Lots more diffs to come to complete the full support. Current RFC API (*in flux based on ongoing feedback*): ``` type AtomDiff = Map<ItemKey, ?Loadable<mixed>>; // null entry means reset useRecoilSync({ syncKey?: SyncKey, // key to match with syncEffect() write?: ({diff: ItemDiff, items: ItemSnapshot}) => void, read?: ItemKey => ?Loadable<mixed>, listen?: (AtomDiff => void) => (() => void), }) => void; ``` ``` function syncEffect<T>(params: { syncKey?: SyncKey, // key to match with useRecoilSync() key?: ItemKey, // defaults to Atom key restore: mixed => ?Loadable<T>, // For advanced use-cases read?: ({read: ItemKey => ?Loadable<mixed>}) => Loadable<mixed>, write?: (Loadable<T>, {read: ItemKey => ?Loadable<mixed>}) => ItemDiff, }): AtomEffect<T> ``` Differential Revision: D30467990 fbshipit-source-id: 67ec37200d9b2832a437116d0c35e29516bcd0e8
drarmstr
added a commit
to drarmstr/Recoil
that referenced
this pull request
Sep 18, 2021
Summary: Pull Request resolved: facebookexperimental#1225 Initial implementation of `recoil-sync` with `useRecoilSync()` hook and `syncEffect()` atom effect. This just includes the basic functionality of registering atoms and reading/writing from storage. Lots more diffs to come to complete the full support. Current RFC API (*in flux based on ongoing feedback*): ``` type AtomDiff = Map<ItemKey, ?Loadable<mixed>>; // null entry means reset useRecoilSync({ syncKey?: SyncKey, // key to match with syncEffect() write?: ({diff: ItemDiff, items: ItemSnapshot}) => void, read?: ItemKey => ?Loadable<mixed>, listen?: (AtomDiff => void) => (() => void), }) => void; ``` ``` function syncEffect<T>(params: { syncKey?: SyncKey, // key to match with useRecoilSync() key?: ItemKey, // defaults to Atom key restore: mixed => ?Loadable<T>, // For advanced use-cases read?: ({read: ItemKey => ?Loadable<mixed>}) => Loadable<mixed>, write?: (Loadable<T>, {read: ItemKey => ?Loadable<mixed>}) => ItemDiff, }): AtomEffect<T> ``` Differential Revision: D30467990 fbshipit-source-id: 594c6cbe8067f1d7917e99e2eca74a250caf51be
drarmstr
added a commit
to drarmstr/Recoil
that referenced
this pull request
Sep 18, 2021
Summary: Pull Request resolved: facebookexperimental#1225 Initial implementation of `recoil-sync` with `useRecoilSync()` hook and `syncEffect()` atom effect. This just includes the basic functionality of registering atoms and reading/writing from storage. Lots more diffs to come to complete the full support. Current RFC API (*in flux based on ongoing feedback*): ``` type AtomDiff = Map<ItemKey, ?Loadable<mixed>>; // null entry means reset useRecoilSync({ syncKey?: SyncKey, // key to match with syncEffect() write?: ({diff: ItemDiff, items: ItemSnapshot}) => void, read?: ItemKey => ?Loadable<mixed>, listen?: (AtomDiff => void) => (() => void), }) => void; ``` ``` function syncEffect<T>(params: { syncKey?: SyncKey, // key to match with useRecoilSync() key?: ItemKey, // defaults to Atom key restore: mixed => ?Loadable<T>, // For advanced use-cases read?: ({read: ItemKey => ?Loadable<mixed>}) => Loadable<mixed>, write?: (Loadable<T>, {read: ItemKey => ?Loadable<mixed>}) => ItemDiff, }): AtomEffect<T> ``` Differential Revision: D30467990 fbshipit-source-id: 49beab1f484c0d8b95335721b98c8b28984dafaf
This pull request has been merged in 795c197. |
drarmstr
added a commit
to drarmstr/Recoil
that referenced
this pull request
Sep 18, 2021
Summary: Pull Request resolved: facebookexperimental#1225 Initial implementation of `recoil-sync` with `useRecoilSync()` hook and `syncEffect()` atom effect. This just includes the basic functionality of registering atoms and reading/writing from storage. Lots more diffs to come to complete the full support. Current RFC API (*in flux based on ongoing feedback*): ``` type AtomDiff = Map<ItemKey, ?Loadable<mixed>>; // null entry means reset useRecoilSync({ syncKey?: SyncKey, // key to match with syncEffect() write?: ({diff: ItemDiff, items: ItemSnapshot}) => void, read?: ItemKey => ?Loadable<mixed>, listen?: (AtomDiff => void) => (() => void), }) => void; ``` ``` function syncEffect<T>(params: { syncKey?: SyncKey, // key to match with useRecoilSync() key?: ItemKey, // defaults to Atom key restore: mixed => ?Loadable<T>, // For advanced use-cases read?: ({read: ItemKey => ?Loadable<mixed>}) => Loadable<mixed>, write?: (Loadable<T>, {read: ItemKey => ?Loadable<mixed>}) => ItemDiff, }): AtomEffect<T> ``` Differential Revision: D30467990 fbshipit-source-id: 8bcc1c5a9f8bb0657588276a8d1b25c0f5da4821
AlexGuz23
pushed a commit
to AlexGuz23/Recoil
that referenced
this pull request
Nov 3, 2022
Summary: Pull Request resolved: facebookexperimental/Recoil#1225 Initial implementation of `recoil-sync` with `useRecoilSync()` hook and `syncEffect()` atom effect. This just includes the basic functionality of registering atoms and reading/writing from storage. Lots more diffs to come to complete the full support. Current RFC API (*in flux based on ongoing feedback*): ``` type AtomDiff = Map<ItemKey, ?Loadable<mixed>>; // null entry means reset useRecoilSync({ syncKey?: SyncKey, // key to match with syncEffect() write?: ({diff: ItemDiff, items: ItemSnapshot}) => void, read?: ItemKey => ?Loadable<mixed>, listen?: (AtomDiff => void) => (() => void), }) => void; ``` ``` function syncEffect<T>(params: { syncKey?: SyncKey, // key to match with useRecoilSync() key?: ItemKey, // defaults to Atom key restore: mixed => ?Loadable<T>, // For advanced use-cases read?: ({read: ItemKey => ?Loadable<mixed>}) => Loadable<mixed>, write?: (Loadable<T>, {read: ItemKey => ?Loadable<mixed>}) => ItemDiff, }): AtomEffect<T> ``` Reviewed By: csantos42 Differential Revision: D30467990 fbshipit-source-id: e35bed04c9fe91b3b33896a93b58d54d0857d4d3
snipershooter0701
pushed a commit
to snipershooter0701/Recoil
that referenced
this pull request
Mar 5, 2023
Summary: Pull Request resolved: facebookexperimental/Recoil#1225 Initial implementation of `recoil-sync` with `useRecoilSync()` hook and `syncEffect()` atom effect. This just includes the basic functionality of registering atoms and reading/writing from storage. Lots more diffs to come to complete the full support. Current RFC API (*in flux based on ongoing feedback*): ``` type AtomDiff = Map<ItemKey, ?Loadable<mixed>>; // null entry means reset useRecoilSync({ syncKey?: SyncKey, // key to match with syncEffect() write?: ({diff: ItemDiff, items: ItemSnapshot}) => void, read?: ItemKey => ?Loadable<mixed>, listen?: (AtomDiff => void) => (() => void), }) => void; ``` ``` function syncEffect<T>(params: { syncKey?: SyncKey, // key to match with useRecoilSync() key?: ItemKey, // defaults to Atom key restore: mixed => ?Loadable<T>, // For advanced use-cases read?: ({read: ItemKey => ?Loadable<mixed>}) => Loadable<mixed>, write?: (Loadable<T>, {read: ItemKey => ?Loadable<mixed>}) => ItemDiff, }): AtomEffect<T> ``` Reviewed By: csantos42 Differential Revision: D30467990 fbshipit-source-id: e35bed04c9fe91b3b33896a93b58d54d0857d4d3
eagle2722
added a commit
to eagle2722/Recoil
that referenced
this pull request
Sep 21, 2024
Summary: Pull Request resolved: facebookexperimental/Recoil#1225 Initial implementation of `recoil-sync` with `useRecoilSync()` hook and `syncEffect()` atom effect. This just includes the basic functionality of registering atoms and reading/writing from storage. Lots more diffs to come to complete the full support. Current RFC API (*in flux based on ongoing feedback*): ``` type AtomDiff = Map<ItemKey, ?Loadable<mixed>>; // null entry means reset useRecoilSync({ syncKey?: SyncKey, // key to match with syncEffect() write?: ({diff: ItemDiff, items: ItemSnapshot}) => void, read?: ItemKey => ?Loadable<mixed>, listen?: (AtomDiff => void) => (() => void), }) => void; ``` ``` function syncEffect<T>(params: { syncKey?: SyncKey, // key to match with useRecoilSync() key?: ItemKey, // defaults to Atom key restore: mixed => ?Loadable<T>, // For advanced use-cases read?: ({read: ItemKey => ?Loadable<mixed>}) => Loadable<mixed>, write?: (Loadable<T>, {read: ItemKey => ?Loadable<mixed>}) => ItemDiff, }): AtomEffect<T> ``` Reviewed By: csantos42 Differential Revision: D30467990 fbshipit-source-id: e35bed04c9fe91b3b33896a93b58d54d0857d4d3
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
enhancement
New feature or request
fb-exported
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
Initial implementation of
recoil-sync
withuseRecoilSync()
hook andsyncEffect()
atom effect. This just includes the basic functionality of registering atoms and reading/writing from storage. Lots more diffs to come to complete the full support.Current RFC API (in flux based on ongoing feedback):
Reviewed By: csantos42
Differential Revision: D30467990