Basic Observer Pattern Implmentation Typescript

Usage no npm install needed!

<script type="module">
  import adriftdevReactiveTs from 'https://cdn.skypack.dev/@adriftdev/reactive-ts';


Reactive - Node

Basic Example

const core = new reactive.Controller()
const weatherStation = new reactive.Subject(core)


core.on('au.com.acme.station/temps', (event) => {
  if (event.source === 'temp_update') {
    console.log('tempData:', event.data)

const tempUpdateEvent = createReactiveEvent(
    temp0: 54,
    temp1: 48,



>> tempData: { temp0: 54, temp1: 48 }

Event Controller

The controllers acts as the hub, provides an interface to manage observers, subjects and channels. allowing subjects and observers to register to channels, and able to emit to any channel that's registered.

Controller by default has access to a special channel called global which is shared amougst all controllers locally.

Creation of a controller is simple:

const core = new Controller()

Event Channel


Reactive Event Structure

  specversion: '1.0'

  type: 'au.com.acme.reactive/update'

  source: 'tempUpdate'

  id: 'e709e3a6-1e01-4209-b7d2-b592446e0011'

  time: '<iso standard time stamp here>'

  datacontenttype: 'application/json'

  data: '<json formatted string>'