8000 GitHub - patrimart/ps-fsa: A reducers generator with functional composition for @ngrx.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

A reducers generator with functional composition for @ngrx.

Notifications You must be signed in to change notification settings

patrimart/ps-fsa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@ngrx-fsa/reducers

A reducers generator with functional composition for @ngrx.

Install

npm i @ngrx-fsa/reducers

Usage

Example:

import { Action, ActionCreator, isType } from "typescript-fsa";
import { caseFn, reducerDefaultFn } from "@ngrx-fsa/reducers";

const actionCreator = actionCreatorFactory();

interface State {
    data: string;
}

const initialState: State = { data: "hello" };

const sliceData = actionCreator<number>("SLICE_DATA");
function sliceDataHandler(state: State, fromIndex: number): State {
    return { data: state.data.slice(fromIndex) };
}

const dataToUpperCase = actionCreator<void>("DATA_TO_UPPERCASE");
function dataToUpperCaseHandler(state: State): State {
    return { data: state.data.toUpperCase() };
}

const reducer = reducerDefaultFn(
    caseFn(sliceData, sliceDataHandler),
    caseFn(dataToUpperCase, dataToUpperCaseHandler),
)(initialState);

About

A reducers generator with functional composition for @ngrx.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0