@pronix/flux
TypeScript icon, indicating that this package has built-in type declarations

1.0.10 • Public • Published

Flux.js

A simple library for creating reactive applications using streams

Getting started

installation:

$ yarn add @pronix/flux

using:

// 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
        }
        // ...
    )

Package Sidebar

Install

npm i @pronix/flux

Weekly Downloads

0

Version

1.0.10

License

MIT

Unpacked Size

23.5 kB

Total Files

21

Last publish

Collaborators

  • pronix