UNPKG

reactant-share

Version:

A framework for building shared web applications with Reactant

67 lines 1.68 kB
import { App, Renderer } from 'reactant'; import { Config } from './interfaces'; /** * ## Description * * You can create an shared app with `createSharedApp()` passing app configuration, * which will asynchronously return an object including `instance`, `store`, * and `bootstrap()` method(You can run `bootstrap` to start the app inject into the browser or mobile). * * ## Example * * ```ts * import { createSharedApp, injectable, state, action, delegate, mockPairTransports } from 'reactant-share'; * * @injectable({ * name: 'counter', * }) * class Counter { * @state * count = 0; * * @action * increase() { * this.count += 1; * } * } * * export default async () => { * const transports = mockPairTransports(); * * const server = await createSharedApp({ * modules: [], * main: Counter, * render: () => {}, * share: { * name: 'counter', * type: 'Base', * port: 'server', * transports: { * server: transports[0], * }, * }, * }); * * const client = await createSharedApp({ * modules: [], * main: Counter, * render: () => {}, * share: { * name: 'counter', * type: 'Base', * port: 'client', * transports: { * client: transports[1], * }, * }, * }); * * await delegate(client.instance, 'increase', []); * * expect(client.instance.count).toBe(1); * expect(server.instance.count).toBe(1); * }; * ``` */ export declare const createSharedApp: <T, S extends any[], R extends Renderer<S>>(options: Config<T, S, R>) => Promise<App<T, S, R>>; //# sourceMappingURL=createApp.d.ts.map