UNPKG

recoil

Version:

Recoil - A state management library for React

60 lines (49 loc) 2.35 kB
/** * 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 { NodeKey } from './Recoil_Keys'; import type { RetainedBy } from './Recoil_RetainedBy'; import type { Retainable, Store, StoreState, TreeState } from './Recoil_State'; const gkx = require('../util/Recoil_gkx'); const nullthrows = require('../util/Recoil_nullthrows'); const recoverableViolation = require('../util/Recoil_recoverableViolation'); const someSet = require('../util/Recoil_someSet'); const { cleanUpNode } = require('./Recoil_FunctionalCore'); const { deleteNodeConfigIfPossible, getNode } = require('./Recoil_Node'); const { RetentionZone } = require('./Recoil_RetentionZone'); // Components that aren't mounted after suspending for this long will be assumed // to be discarded and their resources released. const SUSPENSE_TIMEOUT_MS = 120000; const emptySet = new Set(); declare function releaseRetainablesNowOnCurrentTree(store: Store, retainables: Set<Retainable>): any; declare function findReleasableNodes(store: Store, searchFromNodes: Set<NodeKey>): Set<NodeKey>; // Children before parents declare function getDownstreamNodesInTopologicalOrder(store: any, treeState: any, nodes: Set<NodeKey>, doNotDescendInto1: Set<NodeKey>, doNotDescendInto2: Set<NodeKey>): Array<NodeKey>; declare function releaseNode(store: Store, treeState: TreeState, node: NodeKey): any; declare function nodesRetainedByZone(storeState: StoreState, zone: RetentionZone): Set<NodeKey>; declare function zonesThatCouldRetainNode(node: NodeKey): Array<RetentionZone>; declare function scheduleOrPerformPossibleReleaseOfRetainable(store: Store, retainable: Retainable): any; declare function updateRetainCount(store: Store, retainable: Retainable, delta: 1 | -1): void; declare function updateRetainCountToZero(store: Store, retainable: Retainable): void; declare function releaseScheduledRetainablesNow(store: Store): any; declare function retainedByOptionWithDefault(r: RetainedBy | void): RetainedBy; module.exports = { SUSPENSE_TIMEOUT_MS, updateRetainCount, updateRetainCountToZero, releaseScheduledRetainablesNow, retainedByOptionWithDefault };