From badfabb9c19a29044dd8c56fac649c45c452917a Mon Sep 17 00:00:00 2001 From: Dave McCabe Date: Mon, 17 May 2021 22:54:05 -0700 Subject: [PATCH] TypeScript snapshot.retain Summary: see title Reviewed By: drarmstr Differential Revision: D28489327 fbshipit-source-id: 73949e38084fe01f260f6d8de7c0f19d80a95c55 --- typescript/index.d.ts | 1 + typescript/tests.ts | 3 +++ 2 files changed, 4 insertions(+) diff --git a/typescript/index.d.ts b/typescript/index.d.ts index 6434db13d..9b6e42a3c 100644 --- a/typescript/index.d.ts +++ b/typescript/index.d.ts @@ -55,6 +55,7 @@ export class Snapshot { getInfo_UNSTABLE(recoilValue: RecoilValue): AtomInfo; map(cb: (mutableSnapshot: MutableSnapshot) => void): Snapshot; asyncMap(cb: (mutableSnapshot: MutableSnapshot) => Promise): Promise; + retain(): () => void; } export class MutableSnapshot extends Snapshot { diff --git a/typescript/tests.ts b/typescript/tests.ts index ab3367c44..fb14b46f2 100644 --- a/typescript/tests.ts +++ b/typescript/tests.ts @@ -214,6 +214,9 @@ useRecoilCallback(({ snapshot, set, reset, gotoSnapshot }) => async () => { set(myAtom, 5); set(myAtom, 'hello'); // $ExpectError reset(myAtom); + + const release = snapshot.retain(); + release(); }); /**