Skip to content

Commit 7a22f4c

Browse files
committed
feat: expose $closed
1 parent cbd9292 commit 7a22f4c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export interface BirpcGroupFn<T> {
109109

110110
export type BirpcReturn<RemoteFunctions, LocalFunctions = Record<string, never>> = {
111111
[K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]>
112-
} & { $functions: LocalFunctions, $close: (error?: Error) => void }
112+
} & { $functions: LocalFunctions, $close: (error?: Error) => void, $closed: boolean }
113113

114114
export type BirpcGroupReturn<RemoteFunctions> = {
115115
[K in keyof RemoteFunctions]: BirpcGroupFn<RemoteFunctions[K]>
@@ -210,6 +210,9 @@ export function createBirpc<RemoteFunctions = Record<string, never>, LocalFuncti
210210
if (method === '$close')
211211
return close
212212

213+
if (method === '$closed')
214+
return closed
215+
213216
// catch if "createBirpc" is returned from async function
214217
if (method === 'then' && !eventNames.includes('then' as any) && !('then' in functions))
215218
return undefined

0 commit comments

Comments
 (0)