Skip to content

Commit

Permalink
Incremental cleanup of selector implementation and fix for multiple s…
Browse files Browse the repository at this point in the history
…tores (#1568)

Summary:
Pull Request resolved: #1568

As a follow-on to D33737833 do some more incremental cleanup and simplification of the selector implementation.   Fix async selectors used from multiple stores which were not notifying other stores if they were no longer the latest evaluation in the first store to evaluate it.

Reviewed By: davidmccabe

Differential Revision: D33761732

fbshipit-source-id: 0872f5e243141af04624cb9028ebf7b07e62a226
  • Loading branch information
drarmstr authored and facebook-github-bot committed Jan 26, 2022
1 parent dbca200 commit 0118996
Show file tree
Hide file tree
Showing 4 changed files with 293 additions and 141 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
- Only clone the current snapshot for callbacks if the callback actually uses it. (#1501)
- Cache the cloned snapshots from callbacks unless there was a state change. (#1533)
- Fix transitive selector refresh for some cases (#1409)
- Fix some corner cases with async selectors and multiple stores (#1568)
- Atom Effects
- Rename option from `effects_UNSTABLE` to just `effects` as the interface is mostly stabilizing (#1520)
- Run atom effects when atoms are initialized from a set during a transaction from `useRecoilTransaction_UNSTABLE()` (#1466)
Expand Down
4 changes: 4 additions & 0 deletions packages/recoil/adt/Recoil_Loadable.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ export type Loadable<+T> =
| $ReadOnly<ErrorLoadable<T>>
| $ReadOnly<LoadingLoadable<T>>;

export type ValueLoadableType<+T> = $ReadOnly<ValueLoadable<T>>;
export type ErrorLoadableType<+T> = $ReadOnly<ErrorLoadable<T>>;
export type LoadingLoadableType<+T> = $ReadOnly<LoadingLoadable<T>>;

function loadableWithValue<+T>(value: T): $ReadOnly<ValueLoadable<T>> {
return Object.freeze(new ValueLoadable(value));
}
Expand Down
Loading

0 comments on commit 0118996

Please sign in to comment.