UNPKG

reactant-share

Version:

A framework for building shared web applications with Reactant

48 lines 1.25 kB
import type { ProxyExec } from './interfaces'; /** * Proxy execute On the server side. * * ## Description * * `delegate()` is very similar to the actor model, * which transfers the corresponding module method to the server thread for execution and returns the result as response. * * Note: It does not create new threads, it always runs on the server thread that has already been created. * * ## Example * * ```tsx * import React from 'react'; * import { ViewModule, createApp, injectable, useConnector, action, state, delegate } from 'reactant-share'; * * @injectable({ name: 'counter'}) * class Counter { * @state * count = 0; * * @action * increase() { * this.count += 1; * } * } * * @injectable() * export class AppView extends ViewModule { * constructor(public counter: Counter) { * super(); * } * * component() { * const count = useConnector(() => this.counter.count); * return ( * <button type="button" onClick={() => delegate(this.counter, 'increase', [])}> * {count} * </button> * ); * } * } * ``` * reference: https://en.wikipedia.org/wiki/Actor_model */ export declare const delegate: ProxyExec; //# sourceMappingURL=delegate.d.ts.map