esp-js-ui

The esp-js-ui package builds an app out of modules, and starts them in a fixed order.

An app with one module

ModuleBuilder builds a module: its services, its stores, and the views it shows. AppBuilder builds the app from its modules, and start() runs the modules’ hooks.

This sample is based on the todo module of the example app:

import { AppBuilder, ModuleBuilder } from 'esp-js-ui';
import { registerTodoStore } from './modules/todo/stores/todoStore';
import { TodoView } from './modules/todo/views/todoView';

const todoModule = ModuleBuilder
    .create('todo')
    .withView('todo-store-id', TodoView, 'main')
    .withInitialisation(async ({ eventBus }) => {
        registerTodoStore(eventBus, 'todo-store-id');
    })
    .build();

const app = AppBuilder
    .create('todo-app')
    .withModule(todoModule)
    .build();

await app.start();

registerTodoStore builds the todo store on the app’s bus: see store builder. withView shows TodoView in the main region, connected to that store. To render the app with React, see EspApp.

Pages in this section

  • Bootstrapping: AppBuilder, and what start() and dispose() do.
  • Modules: ModuleBuilder and the context its hooks get.
  • Services: the app container and the module containers.
  • Views: bind a view to a store with withView.
  • Regions: where the views appear in the shell.