Skip to content

vue-mvvm / core / Delegate

Delegate<Arguments> ​

Represents a delegate mechanism for subscribing and invoking callback functions.

Supports sequential and parallel modes for invoking the callbacks.

Type Parameters ​

Arguments ​

Arguments extends any[] = []

Constructors ​

Constructor ​

ts
new Delegate<Arguments>(mode?): Delegate<Arguments>;

Parameters ​

mode? ​

DelegateMode = DelegateMode.SEQUENTIAL

Returns ​

Delegate<Arguments>

Methods ​

dispose() ​

ts
dispose(): void;

Resets the internal state of the object.

This method is typically called in a unmounted hook to remove all unreachable subscribers.

Returns ​

void


invoke() ​

ts
invoke(...args): Promise<void>;

Invokes the appropriate processing method based on the current mode.

Parameters ​

args ​

...Arguments

The arguments to be passed to the registered callbacks.

Returns ​

Promise<void>


subscribe() ​

ts
subscribe(cb): DelegateRevoke;

Subscribes a callback function to the delegate, allowing it to be invoked when the delegate is executed.

Parameters ​

cb ​

DelegateCallback<Arguments>

The callback function to be subscribed to the delegate.

Returns ​

DelegateRevoke

A function that, when called, revokes the subscription of the callback.