Skip to content

Latest commit

 

History

History
40 lines (27 loc) · 901 Bytes

subsystem.md

File metadata and controls

40 lines (27 loc) · 901 Bytes

Subsystem

A subsystem is a modular part of an app responsible for providing a particular functionality to the kernel.

create(subsystemFn)

Creates a subsystem using a subsystem generation function.

Usage

import { Subsystem } from '@skele/classic'

const navigationSubsystem = Subsystem.create(system => {
  return {
    name: 'navigation',
    start: system => console.log('Started the navigation subsystem...'),
  }
})

fromMiddleware(middleware, name)

Creates a subsystem from a middleware.

Usage

import { Kernel, Subsystem, defaultSubsystems } from '@skele/classic'
import { tracking, logging } from './middleware'

const initData = { kind: 'app' }

const middleware = [
  Subsystem.fromMiddleware(tracking, 'tracking'),
  Subsystem.fromMiddleware(logging, 'logging'),
]

Kernel.create([...defaultSubsystems, ...middleware], initData)