0.5.2 • Published 3 years ago

@vividcode/ngrx-helper v0.5.2

Weekly downloads
4
License
MIT
Repository
github
Last release
3 years ago

NgRx Helper

A helper library to make use of NgRx easier. ngrx-helper creates several helper objects to interact with NgRx store.

  • Reducer helper: Create the reducer function for NgRx.
  • Action helper: Send different actions.
  • Effects helper: Create effects to handle different actions.
  • Selector helper: Create selectors.

Usage

Installation

To use ngrx-helper, run npm or yarn to install the package @vividcode/ngrx-helper.

$ npm i @vividcode/ngrx-helper

Create injection tokens

You need to create three injection tokens for ngrx-helper to associate with created helper object.

  • For reducer function, used by NgRx and ngrx-helper
  • For feature name
  • For NgRx helper

The code below shows a list of InjectionTokens for the feature user.

import { InjectionToken } from '@angular/core';

export const featureName = 'user';
export const UserReducerFunctionToken = new InjectionToken(`user reducer function`);
export const UserNameToken = new InjectionToken(`user name`);
export const UserHelperToken = new InjectionToken(`user helper`);

Import module

In your own module, use NgRxHelperModule.forFeature() to create the module for the feature. forFeature() accepts parameters of the feature name, feature name injection token, reducer function injection token and helper injection token.

NgRxHelperModule.forFeature(featureName, UserNameToken,  UserReducerFunctionToken, UserHelperToken)

Then import the NgRx feature module using StoreModule.forFeature. Remember to use the injection token for the reducer function.

StoreModule.forFeature(featureName, UserReducerFunctionToken)

Now the reducer should work.

0.5.2

3 years ago

0.5.0

3 years ago

0.5.1

3 years ago

0.4.0

5 years ago

0.3.5

5 years ago

0.3.4

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago