Skip to content

A simple example of the signals/slots observability pattern, written in TypeScript.

License

Notifications You must be signed in to change notification settings

SmithKy3/signals-slots-ts

Repository files navigation

signals-slots-ts

A simple example of the signals/slots observability pattern, written in TypeScript.

Usage

  • Both CommonJS and ESM entry files are provided.
// CommonJS
const { createSignal } = require('signals-slots-ts');

const myComplexData = myComplexDataFactory();
const mySignal = createSignal(myComplexData);

// ESM
import { createSignal } from 'signals-slots-ts';

const myComplexData = myComplexDataFactory();
const mySignal = createSignal(myComplexData);
  • Connecting / disconnecting callbacks
import { createSignal } from 'signals-slots-ts';

const myComplexData = myComplexDataFactory();
const mySignal = createSignal(myComplexData);

const onMyComplexDataChange = (newComplexData) => {
    console.log(newComplexData);
};
mySingal.connect(onMyComplexDataChange);
mySignal.value.someNumberFieldOfMyComplexData += 1;
// Updated data logged to console.

mySignal.disconnect(onMyComplexDataChange);
mySignal.value.someNumberFieldOfMyComplexData += 1;
// Updated data not logged to console.

About

A simple example of the signals/slots observability pattern, written in TypeScript.

Resources

License

Stars

Watchers

Forks

Packages

No packages published