1.0.10 • Published 5 years ago
@pronix/flux v1.0.10

Flux.js
 
A simple library for creating reactive applications using streams
Getting started
installation:
$ yarn add @pronix/fluxusing:
// TypeScript + es6 modules
import Flux from '@pronix/flux'
interface Person {
    name: string,
    age: number,
    sex: 'male' | 'female' | 'other'
}
const stream = new Flux<Person[]>([])
stream
    .subscribe(
        (data) => console.log(
            data
                .map(p => p.name)
                .join('\n')
        ),
        (data) => {}
        // ...
    )
    .dispatch(
        (data) => {
            data.push({
                name: 'pronix',
                age: 25,
                sex: 'male'
            })
            return data
        }
        // ...
    )// JavaScipt + require
const Flux = require('@pronix/flux').default
const stream = new Flux([])
stream
    .subscribe(
        (data) => console.log(
            data
                .map(p => p.name)
                .join('\n')
        ),
        (data) => {}
        // ...
    )
    .dispatch(
        (data) => {
            data.push({
                name: 'pronix',
                age: 25,
                sex: 'male'
            })
            return data
        }
        // ...
    )