Version: 5.x

single-spa-cycle

single-spa-cycle is a helper library that helps implement single-spa registered application lifecycle functions (bootstrap, mount and unmount) for for use with Cycle.js. Check out the single-spa-cycle github.

  1. npm install --save @pcmnac/single-spa-cycle

In your project’s entry file, add the following:

  1. import {run} from '@cycle/run'
  2. import {makeDOMDriver} from '@cycle/dom'
  3. import singleSpaCycle from '@pcmnac/single-spa-cycle';
  4. import rootComponent from './root.component.js';
  5. const cycleLifecycles = singleSpaCycle({
  6. run,
  7. rootComponent,
  8. drivers: { DOM: makeDOMDriver(document.getElementById('main-content'))}, // or { DOM: makeDOMDriver('#main-content')}
  9. });
  10. export const bootstrap = cycleLifecycles.bootstrap;
  11. export const mount = cycleLifecycles.mount;
  12. export const unmount = cycleLifecycles.unmount;

All options are passed to single-spa-cycle via the opts parameter when calling singleSpaCycle(opts). The following options are available:

  • run: (required) Cycle.js run function.
  • drivers: (required) Drivers (including DOM Driver) to be used by your Cycle.js root component.
  • rootComponent: (required) The top level Cycle.js component which will be rendered

Cycle - 图1Edit this page