Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/re-js/tfrp

Transparent Functional Reactive Programming
https://github.com/re-js/tfrp

decorators functional reactive remini trfp

Last synced: about 2 months ago
JSON representation

Transparent Functional Reactive Programming

Awesome Lists containing this project

README

        

# Class decorators for TFRP

[![npm version](https://img.shields.io/npm/v/tfrp?style=flat-square)](https://www.npmjs.com/package/tfrp)
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/tfrp?style=flat-square)](https://bundlephobia.com/result?p=tfrp)
[![code coverage](https://img.shields.io/coveralls/github/re-js/tfrp?style=flat-square)](https://coveralls.io/github/re-js/tfrp)
[![typescript supported](https://img.shields.io/npm/types/typescript?style=flat-square)](./src/index.d.ts)

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.

```javascript
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.

```javascript
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](https://github.com/betula/babel-plugin-jsx-wrapper) for automatic observation arrow function components if you want.