JSPM

@dobschal/observable

1.0.6
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7
  • Score
    100M100P100Q42784F
  • License WTFPL

Turn any variable into an observable object.

Package Exports

  • @dobschal/observable
  • @dobschal/observable/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@dobschal/observable) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Observable

A simple Observable implementation in JavaScript.

Test NPM

Installation

npm install --save @dobschal/observable

Usage

Observe values and get notified when they change:

import { Observable } from '@dobschal/observable';

const count = Observable(5);

count.subscribe(value => {
  console.log(value);
});

count.set(10); // will trigger the subscription and log 10
count.value = 15; // will trigger the subscription and log 15

Watch computed values:

import { Computed, Observable } from '@dobschal/observable';

const count = Observable(5);
const multiplied = Computed(() => count.value * 2);

multiplied.subscribe(value => {
  console.log(value);
});