typeAtomEffect<T> = ({ node: RecoilState<T>, // 对 atom 本身的引用 storeID: StoreID, // ID for the <RecoilRoot> or Snapshot store associated with this effect. // ID for the parent Store the current instance was cloned from. For example, // the host <RecoilRoot> store for `useRecoilCallback()` snapshots. parentStoreID_UNSTABLE: StoreID, trigger: 'get' | 'set', // 触发 atom 初始化的行动
// 用于设置或重置 atom 值的回调。 // 可以从 atom effect 函数中直接调用,以初始化 // atom 的初始值,或者在以后异步调用以改变它。 setSelf: ( | T | DefaultValue | Promise<T | DefaultValue> // 目前只能用于初始化 | ((T | DefaultValue) => T | DefaultValue), ) =>void, resetSelf: () =>void,
// 订阅 atom 值的变化。 // 由于这个 effect 自己的 setSelf() 的变化,该回调没有被调用。 onSet: ( (newValue: T | DefaultValue, oldValue: T | DefaultValue) => void, ) =>void, // Callbacks to read other atoms/selectors getPromise: <S>(RecoilValue<S>) =>Promise<S>, getLoadable: <S>(RecoilValue<S>) =>Loadable<S>, getInfo_UNSTABLE: <S>(RecoilValue<S>) =>RecoilValueInfo<S>,