UNPKG

thorish

Version:

This is a library of useful JS concepts and data structures for Node and the browser. It it, unashamedly, a dumping ground for code needed by [@samthor](https://twitter.com/samthor)'s projects.

26 lines (25 loc) 929 B
export type ActiveCall<In, Out> = { gen: AsyncGenerator<In, Error | void, void>; send(data: Out): void; }; export type RemoteCall<Init = never> = { call<In = any, Out = any>(signal: AbortSignal): ActiveCall<In, Out>; init: Init; done: Promise<void>; }; /** * Starts a connection to the remote URL. * * Notably this does not deal with r/c; it returns a {@link Promise} that resolves when ready. * Use the returned {@link RemoteCall} to call on _this active connection only_. * * Uses the protocol as implemented here: https://pkg.go.dev/github.com/samthor/thorgo/call */ export declare function startRemoteCall<Init = never>(signal: AbortSignal, url: string): Promise<RemoteCall<Init>>; /** * Wraps a 'normal' shutdown from the remote end of a {@link RemoteCall} / {@link ActiveCall}. */ export declare class RemoteCallError extends Error { readonly stop: string; constructor(stop: string); }