Skip to content

Commit

Permalink
TypeScript snapshot.retain
Browse files Browse the repository at this point in the history
Summary: see title

Reviewed By: drarmstr

Differential Revision: D28489327

fbshipit-source-id: 73949e38084fe01f260f6d8de7c0f19d80a95c55
  • Loading branch information
davidmccabe authored and facebook-github-bot committed May 18, 2021
1 parent f5dae49 commit badfabb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions typescript/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export class Snapshot {
getInfo_UNSTABLE<T>(recoilValue: RecoilValue<T>): AtomInfo<T>;
map(cb: (mutableSnapshot: MutableSnapshot) => void): Snapshot;
asyncMap(cb: (mutableSnapshot: MutableSnapshot) => Promise<void>): Promise<Snapshot>;
retain(): () => void;
}

export class MutableSnapshot extends Snapshot {
Expand Down
3 changes: 3 additions & 0 deletions typescript/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ useRecoilCallback(({ snapshot, set, reset, gotoSnapshot }) => async () => {
set(myAtom, 5);
set(myAtom, 'hello'); // $ExpectError
reset(myAtom);

const release = snapshot.retain();
release();
});

/**
Expand Down

0 comments on commit badfabb

Please sign in to comment.