0.0.5 • Published 6 years ago

reactiveproperty-rxjs v0.0.5

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

ReactiveProperty & ReactiveCollection implementations for rxjs5

Inspired by implementation in other languages e.g. UniRx

  1. ReactiveProperty
const { ReactiveProperty } = require("reactiveproperty-rxjs");

const MyClass {
  this.myProperty = new ReactiveProperty(); // could be undefined
}

const myInstnace = new MyClass();

myInstance.myProperty.subscribe(x => console.log(`first subscriber: ${x}`)); // you can work with the prop as any other observable -> filer, map, merge etc.

myInstance.myProperty.value = 20; // this value will be propagated to all subscribers

myInstance.myProperty.subscribe(x => console.log(`second subscriber: ${x}`));

myInstance.myProperty.value = 30;
// RESULT:
first subscriber: 20
second subscriber: 20
first subscriber: 30
second subscriber: 30
  1. ReactiveProperty - default value (if the default value is empty - it will not be send immediately to new subscribers)
const { ReactiveProperty } = require("reactiveproperty-rxjs");

const MyClass {
  this.myProperty = new ReactiveProperty(10); // could be undefined
}

const myInstnace = new MyClass();

myInstance.myProperty.subscribe(x => console.log(`first subscriber: ${x}`)); // you can work with the prop as any other observable -> filer, map, merge etc.

myInstance.myProperty.value = 20; // this value will be propagated to all subscribers

myInstance.myProperty.subscribe(x => console.log(`second subscriber: ${x}`));

myInstance.myProperty.value = 30;
// RESULT:
first subscriber: 10
first subscriber: 20
second subscriber: 20
first subscriber: 30
second subscriber: 30

TODO: add toReactiveProperty() and ReactiveCollection support

0.0.5

6 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago