/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @emails oncall+recoil * @flow strict-local * @format */ 'use strict'; import type { Loadable } from '../adt/Recoil_Loadable'; import type { ValueOrUpdater } from '../recoil_values/Recoil_callbackTypes'; import type { AtomValues, AtomWrites, NodeKey, Store, TreeState } from './Recoil_State'; const { CANCELED } = require('../adt/Recoil_Loadable'); const nullthrows = require('../util/Recoil_nullthrows'); const recoverableViolation = require('../util/Recoil_recoverableViolation'); const { getDownstreamNodes, getNodeLoadable, setNodeValue } = require('./Recoil_FunctionalCore'); const { getNodeMaybe } = require('./Recoil_Node'); const { DefaultValue, RecoilValueNotReady } = require('./Recoil_Node'); const { AbstractRecoilValue, RecoilState, RecoilValueReadOnly, isRecoilValue } = require('./Recoil_RecoilValue'); declare function getRecoilValueAsLoadable(store: Store, arg1: AbstractRecoilValue, treeState: TreeState): Loadable; declare function applyAtomValueWrites(atomValues: AtomValues, writes: AtomWrites): AtomValues; declare function valueFromValueOrUpdater(store: Store, state: TreeState, arg2: AbstractRecoilValue, valueOrUpdater: ValueOrUpdater): T | DefaultValue; type Action = { type: 'set', recoilValue: AbstractRecoilValue, valueOrUpdater: T | DefaultValue | ((T) => T | DefaultValue), } | { type: 'setLoadable', recoilValue: AbstractRecoilValue, loadable: Loadable, } | { type: 'setUnvalidated', recoilValue: AbstractRecoilValue, unvalidatedValue: mixed, } | { type: 'markModified', recoilValue: AbstractRecoilValue, }; declare function applyAction(store: Store, state: TreeState, action: Action): any; declare function writeLoadableToTreeState(state: TreeState, key: NodeKey, loadable: Loadable): void; declare function applyActionsToStore(store: any, actions: any): any; declare function queueOrPerformStateUpdate(store: Store, action: Action): void; const batchStack: Array>>> = []; declare function batchStart(): () => void; declare function copyTreeState(state: any): any; declare function invalidateDownstreams(store: Store, state: TreeState): void; declare function setRecoilValue(store: Store, recoilValue: AbstractRecoilValue, valueOrUpdater: T | DefaultValue | ((T) => T | DefaultValue)): void; declare function setRecoilValueLoadable(store: Store, recoilValue: AbstractRecoilValue, loadable: DefaultValue | Loadable): void; declare function markRecoilValueModified(store: Store, recoilValue: AbstractRecoilValue): void; declare function setUnvalidatedRecoilValue(store: Store, recoilValue: AbstractRecoilValue, unvalidatedValue: T): void; export type ComponentSubscription = { release: () => void }; let subscriptionID = 0; declare function subscribeToRecoilValue(store: Store, arg1: AbstractRecoilValue, callback: (TreeState) => void, componentDebugName: ?string): ComponentSubscription; module.exports = { RecoilValueReadOnly, AbstractRecoilValue, RecoilState, getRecoilValueAsLoadable, setRecoilValue, setRecoilValueLoadable, markRecoilValueModified, setUnvalidatedRecoilValue, subscribeToRecoilValue, isRecoilValue, applyAtomValueWrites, // TODO Remove export when deprecating initialStoreState_DEPRECATED in RecoilRoot batchStart, invalidateDownstreams_FOR_TESTING: invalidateDownstreams };