1 | /// <reference types="react" />
|
2 | import { Reaction } from "mobx";
|
3 | export declare function createTrackingData(reaction: Reaction): IReactionTracking;
|
4 | /**
|
5 | * Unified api for timers/Finalization registry cleanups
|
6 | * This abstraction make useObserver much simpler
|
7 | */
|
8 | export interface ReactionCleanupTracking {
|
9 | /**
|
10 | *
|
11 | * @param reaction The reaction to cleanup
|
12 | * @param objectRetainedByReact This will be in actual use only when FinalizationRegister is in use
|
13 | */
|
14 | addReactionToTrack(reactionTrackingRef: React.MutableRefObject<IReactionTracking | null>, reaction: Reaction, objectRetainedByReact: object): IReactionTracking;
|
15 | recordReactionAsCommitted(reactionRef: React.MutableRefObject<IReactionTracking | null>): void;
|
16 | forceCleanupTimerToRunNowForTests(): void;
|
17 | resetCleanupScheduleForTests(): void;
|
18 | }
|
19 | export interface IReactionTracking {
|
20 | /** The Reaction created during first render, which may be leaked */
|
21 | reaction: Reaction;
|
22 | /**
|
23 | * The time (in ticks) at which point we should dispose of the reaction
|
24 | * if this component hasn't yet been fully mounted.
|
25 | */
|
26 | cleanAt: number;
|
27 | /**
|
28 | * Whether the component has yet completed mounting (for us, whether
|
29 | * its useEffect has run)
|
30 | */
|
31 | mounted: boolean;
|
32 | /**
|
33 | * Whether the observables that the component is tracking changed between
|
34 | * the first render and the first useEffect.
|
35 | */
|
36 | changedBeforeMount: boolean;
|
37 | /**
|
38 | * In case we are using finalization registry based cleanup,
|
39 | * this will hold the cleanup token associated with this reaction
|
40 | */
|
41 | finalizationRegistryCleanupToken?: number;
|
42 | }
|
43 | /**
|
44 | * The minimum time before we'll clean up a Reaction created in a render
|
45 | * for a component that hasn't managed to run its effects. This needs to
|
46 | * be big enough to ensure that a component won't turn up and have its
|
47 | * effects run without being re-rendered.
|
48 | */
|
49 | export declare const CLEANUP_LEAKED_REACTIONS_AFTER_MILLIS = 10000;
|
50 | /**
|
51 | * The frequency with which we'll check for leaked reactions.
|
52 | */
|
53 | export declare const CLEANUP_TIMER_LOOP_MILLIS = 10000;
|