Skip to content

Commit

Permalink
refactor: rename variables
Browse files Browse the repository at this point in the history
  • Loading branch information
exuanbo committed Oct 23, 2024
1 parent 41feb82 commit d6dbf4f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/utils/context.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// @internal
export function createContext<T extends {}>() {
let contextValue: T | null = null;
let current: T | null = null;

function provide<R>(value: T, callback: () => R) {
const currentValue = contextValue;
contextValue = value;
function provide<R>(next: T, fn: () => R) {
const prev = current;
try {
return callback();
current = next;
return fn();
}
finally {
contextValue = currentValue;
current = prev;
}
}

function use() {
return contextValue;
return current;
}

return <const>[
Expand Down

0 comments on commit d6dbf4f

Please sign in to comment.