Skip to content

Repository files navigation

Observable

A simple Observable implementation in JavaScript.

TestNPM

Installation

npm install --save @dobschal/observable

Usage

Observe values and get notified when they change:

import{Observable}from'@dobschal/observable';constcount=Observable(5);count.subscribe(value=>{console.log(value);});count.set(10);// will trigger the subscription and log 10count.value=15;// will trigger the subscription and log 15

Watch computed values:

import{Computed,Observable}from'@dobschal/observable';constcount=Observable(5);constmultiplied=Computed(()=>count.value*2);multiplied.subscribe(value=>{console.log(value);});

About

πŸ’‘ A simple Observable implementation for JavaScript/TypeScript. Allowing you to observe a value and get notified whenever it is changed.

Topics

Resources

Stars

1 star

Watchers

2 watching

Forks

Releases

Used by

Contributors

Languages