@zaibot/fsa
v0.2.0
Published
Easy type checked Flux Standard Action for TypeScript
Downloads
5
Readme
@zaibot/fsa
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);
}