Skip to content

Commit 38eabe3

Browse files
committed
port withScope
1 parent 764be24 commit 38eabe3

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

packages/hub/src/exports.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,20 @@ export function setTag(key: string, value: Primitive): ReturnType<Hub['setTag']>
143143
export function setUser(user: User | null): ReturnType<Hub['setUser']> {
144144
getCurrentHub().setUser(user);
145145
}
146+
147+
/**
148+
* Creates a new scope with and executes the given operation within.
149+
* The scope is automatically removed once the operation
150+
* finishes or throws.
151+
*
152+
* This is essentially a convenience function for:
153+
*
154+
* pushScope();
155+
* callback();
156+
* popScope();
157+
*
158+
* @param callback that will be enclosed into push/popScope.
159+
*/
160+
export function withScope(callback: (scope: Scope) => void): ReturnType<Hub['withScope']> {
161+
getCurrentHub().withScope(callback);
162+
}

packages/minimal/src/index.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,6 @@ function callOnHub<T>(method: string, ...args: any[]): T {
2929
throw new Error(`No hub defined or ${method} was not found on the hub, please open a bug report.`);
3030
}
3131

32-
/**
33-
* Creates a new scope with and executes the given operation within.
34-
* The scope is automatically removed once the operation
35-
* finishes or throws.
36-
*
37-
* This is essentially a convenience function for:
38-
*
39-
* pushScope();
40-
* callback();
41-
* popScope();
42-
*
43-
* @param callback that will be enclosed into push/popScope.
44-
*/
45-
export function withScope(callback: (scope: Scope) => void): void {
46-
callOnHub<void>('withScope', callback);
47-
}
48-
4932
/**
5033
* Calls a function on the latest client. Use this with caution, it's meant as
5134
* in "internal" helper so we don't need to expose every possible function in

0 commit comments

Comments
 (0)