Easy type checked Flux Standard Action for TypeScript
npm i -S @zaibot/fsa
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);
}