Have ideas to improve npm?Join in the discussion! »

@zaibot/fsa
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

@zaibot/fsa Coverage Status Build Status

Easy type checked Flux Standard Action for TypeScript

Installation

npm i -S @zaibot/fsa

Usage

import { Action, isType } from '@zaibot/fsa';
 
export const HELLO_WORLD = Action<{ message: string; }>('HELLO_WORLD');
 
const action = HELLO_WORLD({ message: 'Hello World!' });
if (isType(action, HELLO_WORLD)) {
    console.log(action.payload.message);
}
import { Action, isTypeOneOf } from '@zaibot/fsa';
 
export const HELLO_WORLD = Action<{ message: string; }>('HELLO_WORLD');
export const WELCOME_MESSAGE = Action<{ message: string; }>('WELCOME_MESSAGE');
 
const action = HELLO_WORLD({ message: 'Hello World!' });
if (isTypeOneOf(action, HELLO_WORLD, WELCOME_MESSAGE)) {
    console.log(action.payload.message);
}

Install

npm i @zaibot/fsa

DownloadsWeekly Downloads

16

Version

0.2.0

License

MIT

Unpacked Size

33.3 kB

Total Files

63

Last publish

Collaborators

  • avatar