https://github.com/zaibot/fsa
Easy type checked Flux Standard Action for TypeScript
https://github.com/zaibot/fsa
fsa redux typescript
Last synced: 2 months ago
JSON representation
Easy type checked Flux Standard Action for TypeScript
- Host: GitHub
- URL: https://github.com/zaibot/fsa
- Owner: Zaibot
- License: mit
- Created: 2017-08-23T18:41:53.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2020-07-04T19:39:30.000Z (almost 6 years ago)
- Last Synced: 2025-02-11T22:34:17.547Z (over 1 year ago)
- Topics: fsa, redux, typescript
- Language: JavaScript
- Homepage:
- Size: 104 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @zaibot/fsa [](https://coveralls.io/github/Zaibot/fsa?branch=master) [](https://travis-ci.org/Zaibot/fsa)
Easy type checked Flux Standard Action for TypeScript
## Installation
```sh
npm i -S @zaibot/fsa
```
## Usage
```ts
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);
}
```
```ts
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);
}
```