0.9.1 • Published 2 years ago

tfrp v0.9.1

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

Class decorators for TFRP

npm version npm bundle size code coverage typescript supported

Transparent Functional Reactive Programming

prop - reactive value marker decorator. Each reactive value has an immutable state. If the immutable state will update, all who depend on It will refresh.

import { prop } from 'tfrp';
import { on } from 'remini';

class Todos {
  @prop items = [];

  constructor() {
    on(() => this.items, () => console.log('items changed'));
  }

  add(todo: string) {
    this.items = this.items.concat(todo); // an immutable modification
  }
}

cache - is the decorator for define selector on class getter.

import { prop, cache } from 'tfrp';

class Todos {
  @prop items = [];

  @cache get completed() {
    return this.items.filter(item => item.completed);
  }
}

You can configure babel jsx wrapper for automatic observation arrow function components if you want.