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

0.9.1 • Public • Published

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.

/tfrp/

    Package Sidebar

    Install

    npm i tfrp

    Weekly Downloads

    4

    Version

    0.9.1

    License

    MIT

    Unpacked Size

    6.99 kB

    Total Files

    10

    Last publish

    Collaborators

    • betula