melv_observable
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

melv_observable

A class containing a private value and a set of functions to run whenever the value is updated.

Examples

const countObservable = new Observable<number>();

const stopLoggingCount = countObservable.subscribe((count) => {
  console.log(`count: ${count}`);
});

countObservable.value = 0; // logs "count: 0"

setInterval(() => {
  countObservable.value++;
  if (countObservable.value === 5)
    stopLoggingCount();
}, 1000); // increments and logs count every second

Readme

Keywords

Package Sidebar

Install

npm i melv_observable

Weekly Downloads

0

Version

2.0.1

License

ISC

Unpacked Size

4.07 kB

Total Files

8

Last publish

Collaborators

  • melvdouc