Comparing version 0.6.1 to 0.7.0
# Change Log | ||
## UPCOMING | ||
**_Add new changes here as they land_** | ||
## 0.6 () | ||
## 0.7 (2022-03-25) | ||
### New Features | ||
- The `default` value is now optional for `atom()` and `atomFamily()`. If not provided the atom will initialize to a pending state. (#1639) | ||
- Add `getStoreID()` method to `Snapshot` (#1612) | ||
- Publish `RecoilLoadable.loading()` factory for making an async `Loadable` which never resolves. (#1641) | ||
### Breaking Changes | ||
- Selector's `get()` and Atom's `default` can now accept a `Loadable` to put the node in that state. | ||
If you wish to store a `Loadable`, `Promise`, or `RecoilValue` directly you can wrap it with `selector.value()` or `atom.value()`. (#1640) | ||
- `useRecoilCallback()` now provides a snapshot for the latest state instead of the latest rendered state, which had bugs (#1610, #1604) | ||
### Improvements / Optimizations | ||
- Automatically retain snapshots for the duration of async callbacks. (#1632) | ||
- Optimization for more selector dependencies. 2x improvement with 100 dependencies, 4x with 1,000, and now able to support 10,000+. (#1651, #1515, #914) | ||
- Better error reporting when selectors provide inconsistent results (#1696) | ||
### Fixes | ||
- Avoid spurious console errors from effects when calling `setSelf()` from `onSet()` handlers. (#1589, #1582) | ||
- Freezing user values in dev mode now works in JS environments without the `Window` interface. (#1571) | ||
## 0.6.1 (2022-01-29) | ||
- Fix postInstall script (#1577) | ||
## 0.6 (2022-01-28) | ||
- React 18 | ||
@@ -25,2 +49,3 @@ - Leverage new React 18 APIs for improved safety and optimizations. (#1488) | ||
### Other Fixes and Optimizations | ||
- Reduce overhead of snapshot cloning | ||
@@ -32,7 +57,6 @@ - Only clone the current snapshot for callbacks if the callback actually uses it. (#1501) | ||
- Atom Effects | ||
- Run atom effects when atoms are initialized from a set during a transaction from `useRecoilTransaction_UNSTABLE()` (#1466) | ||
- Run atom effects when atoms are initialized from a set during a transaction from `useRecoilTransaction_UNSTABLE()` (#1466, #1569) | ||
- Atom effects are cleaned up when initialized by a Snapshot which is released. (#1511, #1532) | ||
- Unsubscribe `onSet()` handlers in atom effects when atoms are cleaned up. (#1509) | ||
- Call `onSet()` when atoms are initialized with `<RecoilRoot initializeState={...} >` (#1519, #1511) | ||
- Set `trigger` to `'set'` when initialized from a set in a Recoil transaction. (#1569) | ||
- Avoid extra re-renders in some cases when a component uses a different atom/selector. (#825) | ||
@@ -39,0 +63,0 @@ - `<RecoilRoot>` will only call `initializeState()` once during the initial render. (#1372) |
@@ -80,2 +80,7 @@ // Minimum TypeScript Version: 3.7 | ||
declare const WrappedValue_OPAQUE: unique symbol; | ||
export interface WrappedValue<T> { | ||
readonly [WrappedValue_OPAQUE]: true; | ||
} | ||
// Effect is called the first time a node is used with a <RecoilRoot> | ||
@@ -109,9 +114,12 @@ export type AtomEffect<T> = (param: { | ||
// atom.d.ts | ||
export interface AtomOptions<T> { | ||
key: NodeKey; | ||
default: RecoilValue<T> | Promise<T> | T; | ||
effects?: ReadonlyArray<AtomEffect<T>>; | ||
effects_UNSTABLE?: ReadonlyArray<AtomEffect<T>>; | ||
dangerouslyAllowMutability?: boolean; | ||
interface AtomOptionsWithoutDefault<T> { | ||
key: NodeKey; | ||
effects?: ReadonlyArray<AtomEffect<T>>; | ||
effects_UNSTABLE?: ReadonlyArray<AtomEffect<T>>; | ||
dangerouslyAllowMutability?: boolean; | ||
} | ||
interface AtomOptionsWithDefault<T> extends AtomOptionsWithoutDefault<T> { | ||
default: RecoilValue<T> | Promise<T> | Loadable<T> | WrappedValue<T> | T; | ||
} | ||
export type AtomOptions<T> = AtomOptionsWithoutDefault<T> | AtomOptionsWithDefault<T>; | ||
@@ -122,2 +130,5 @@ /** | ||
export function atom<T>(options: AtomOptions<T>): RecoilState<T>; | ||
export namespace atom { | ||
function value<T>(value: T): WrappedValue<T>; | ||
} | ||
@@ -178,3 +189,3 @@ export type GetRecoilValue = <T>(recoilVal: RecoilValue<T>) => T; | ||
getCallback: GetCallback, | ||
}) => Promise<T> | RecoilValue<T> | T; | ||
}) => Promise<T> | RecoilValue<T> | Loadable<T> | WrappedValue<T> | T; | ||
dangerouslyAllowMutability?: boolean; | ||
@@ -200,2 +211,5 @@ cachePolicy_UNSTABLE?: CachePolicyWithoutEquality; // TODO: using the more restrictive CachePolicyWithoutEquality while we discuss long term API | ||
export function selector<T>(options: ReadOnlySelectorOptions<T>): RecoilValueReadOnly<T>; | ||
export namespace selector { | ||
function value<T>(value: T): WrappedValue<T>; | ||
} | ||
@@ -391,10 +405,21 @@ // hooks.d.ts | ||
export interface AtomFamilyOptions<T, P extends SerializableParam> { | ||
interface AtomFamilyOptionsWithoutDefault<T, P extends SerializableParam> { | ||
key: NodeKey; | ||
dangerouslyAllowMutability?: boolean; | ||
default: RecoilValue<T> | Promise<T> | T | ((param: P) => T | RecoilValue<T> | Promise<T>); | ||
effects?: | ReadonlyArray<AtomEffect<T>> | ((param: P) => ReadonlyArray<AtomEffect<T>>); | ||
effects_UNSTABLE?: | ReadonlyArray<AtomEffect<T>> | ((param: P) => ReadonlyArray<AtomEffect<T>>); | ||
// cachePolicyForParams_UNSTABLE?: CachePolicyWithoutEviction; TODO: removing while we discuss long term API | ||
} | ||
} | ||
interface AtomFamilyOptionsWithDefault<T, P extends SerializableParam> extends AtomFamilyOptionsWithoutDefault<T, P> { | ||
default: | ||
| RecoilValue<T> | ||
| Promise<T> | ||
| Loadable<T> | ||
| WrappedValue<T> | ||
| T | ||
| ((param: P) => T | RecoilValue<T> | Promise<T> | Loadable<T> | WrappedValue<T>); | ||
} | ||
export type AtomFamilyOptions<T, P extends SerializableParam> = | ||
| AtomFamilyOptionsWithDefault<T, P> | ||
| AtomFamilyOptionsWithoutDefault<T, P>; | ||
@@ -413,3 +438,3 @@ /** | ||
getCallback: GetCallback, | ||
}) => Promise<T> | RecoilValue<T> | T; | ||
}) => Promise<T> | RecoilValue<T> | Loadable<T> | WrappedValue<T> | T; | ||
// cachePolicyForParams_UNSTABLE?: CachePolicyWithoutEviction; TODO: removing while we discuss long term API | ||
@@ -425,3 +450,3 @@ cachePolicy_UNSTABLE?: CachePolicyWithoutEquality; // TODO: using the more restrictive CachePolicyWithoutEquality while we discuss long term API | ||
getCallback: GetCallback, | ||
}) => Promise<T> | RecoilValue<T> | T; | ||
}) => Promise<T> | Loadable<T> | WrappedValue<T> | RecoilValue<T> | T; | ||
set: ( | ||
@@ -534,2 +559,6 @@ param: P, | ||
/** | ||
* Factory to make a loading Loadable which never resolves. | ||
*/ | ||
function loading(): LoadingLoadable<any>; | ||
/** | ||
* Factory to make a Loadable which is resolved when all of the Loadables provided | ||
@@ -536,0 +565,0 @@ * to it are resolved or any one has an error. The value is an array of the values |
{ | ||
"name": "recoil", | ||
"version": "0.6.1", | ||
"version": "0.7.0", | ||
"description": "Recoil - A state management library for React", | ||
@@ -70,3 +70,3 @@ "main": "cjs/recoil.js", | ||
"flow-bin": "^0.164.0", | ||
"gen-flow-files": "https://github.com/drarmstr/gen-flow-files.git", | ||
"flow-copy-source": "^2.0.9", | ||
"hermes-eslint": "^0.4.8", | ||
@@ -73,0 +73,0 @@ "husky": ">=4", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2151457
105
30040