1.1.1 • Published 2 years ago

@hetrodo/observable v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Observable Logo

Downloads

Observable is a simple and lightweight implementation of the observable pattern in nodejs, it fires events when properties are changed.

But note that only the root properties of objects are observed.

Supported types

  • Object
  • Array
  • Primitives (string, number, boolean, null, undefined)

Installation

npm install @hetrodo/observable

Usage

const Observable = require("@hetrodo/observable");

const counter = new Observable(0); //Create a new observable with the initial value of 0

counter.subscribe((value) => {
    console.log(value); //Subscribe to the observable, this will print the value of the observable every time it changes
});

setInterval(() => {
    counter.value++; //Increment the value of the observable every second
}, 1000);
1.1.1

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago