4.0.14 • Published 3 years ago

ngx-painless-redux v4.0.14

Weekly downloads
134
License
-
Repository
-
Last release
3 years ago

NgxPainlessRedux

Description

This is painless-redux adapter for Angular using @ngrx/store.

Install:

  1. npm i painless-redux ngx-painless-redux @ngrx/store
  2. Import NgxPainlessReduxModule to your app module next to StoreModule from @ngrx/store, then import actionSanitizer from painless-redux and add it as actionSanitizer for StoreDevtoolsModule.instrument param:
import { NgxPainlessReduxModule } from 'ngx-painless-redux';
import { actionSanitizer } from 'painless-redux';

@NgModule({
  declarations: [
    AppComponent,
  ],
  imports: [
    BrowserModule,
    StoreModule.forRoot({}),
    StoreDevtoolsModule.instrument({
      actionSanitizer, // <-- here
    }),
    NgxPainlessReduxModule, // <-- here
  ],
  bootstrap: [AppComponent],
})
export class AppModule {}
  1. Inherit from EntityStorageService:
import { Injectable } from '@angular/core';
import { EntityStorageService } from 'ngx-painless-redux';

export interface Entity1 {
  id: string;
  name: string;
  age: number;
}

@Injectable({ providedIn: 'root' })
export class Entity1Storage extends EntityStorageService<Entity1> {

  constructor() {
    super({ name: 'Entity1', pageSize: 2, maxPagesCount: 2 });
  }
}
  1. or from WorkspaceStorageService:
import { Injectable } from '@angular/core';
import { WorkspaceStorageService } from 'ngx-painless-redux';

export interface Workspace1 {
  filter: number[];
}

@Injectable({ providedIn: 'root' })
export class Workspace1Storage extends WorkspaceStorageService<Workspace1> {

  constructor() {
    super({
      name: 'Workspace1', 
      initialValue: {
        filter: [1, 2, 3],
      },
    });
  }
}
  1. inject it to your components / services
4.0.14

3 years ago

4.0.13

3 years ago

4.0.12

3 years ago

4.0.11

4 years ago

4.0.9

4 years ago

4.0.8

4 years ago

0.0.0

4 years ago

4.0.10

4 years ago

4.0.7

4 years ago

4.0.6

4 years ago

4.0.5

4 years ago

4.0.4

4 years ago

4.0.3

4 years ago

4.0.2

4 years ago

4.0.1

4 years ago

4.0.0

4 years ago

0.0.1

4 years ago