Skip to main content

Module: fork

Functions​

fork​

▸ fork<T, K, O>(module, key, args, options?): O extends false ? void : ReturnType<T[K]> extends Promise<R> ? Promise<R> : Promise<ReturnType<T[K]>>

Proxy execute On the client side.

Description​

fork() is very similar to the actor model, which transfers the corresponding module method to all client threads for execution and returns the result from the first client's response.

Note: It does not create new threads, it always runs on all client thread that have already been created.

reference: https://en.wikipedia.org/wiki/Actor_model

Type parameters​

NameType
Textends Record<string | number | symbol, any>
Kextends string | number | symbol
Oextends undefined | boolean

Parameters​

NameTypeDescription
moduleTDesignate an execution module from the server side.
keyKSpecify the name of a method in this module.
argsParameters<T[K]>Pass in the parameters for this method.
options?{ clientIds?: string[] ; portName?: string ; respond?: O } & Pick<EmitParameter<any>, "timeout" | "_extra" | "silent" | "skipBeforeEmit">proxy execution options

Returns​

O extends false ? void : ReturnType<T[K]> extends Promise<R> ? Promise<R> : Promise<ReturnType<T[K]>>

Defined in​

interfaces.ts:209