0.1.0 • Published 4 years ago

@spellcodes/ngrx-compose v0.1.0

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

NGRX Compose

Quick Start

  • npm i @spellcodes/ngrx-compose
  • Include NgrxComposeModule in your module
  • Create store/containers/my-container.container.ts
  • Compose your first container

    @Injectable({ providedIn: 'root' })
    export class EmployeeContainer {
      employeeListContainer:       ContainerShip<EmployeeListDTO>;
      employeeDetailsContainer:    ContainerShip<EmployeeListDTO>;
      employeeOfTheMonthContainer: ContainerShip<EmployeeOfTheMonthDTO>;
    
      constructor(
        private readonly ngrxComposeService: NgrxComposeService,
      ) {
        this.employeeListContainer = ({ company }) =>
          this.ngrxComposeService.createContainer(loadEmployeeList({ company }));
    
        this.employeeDetailsContainer = ({ company }) =>
          this.ngrxComposeService.createContainer(
            loadEmployeeDetails(),
            [
              this.employeeListContainer({ company }),
            ],
          );
    
        this.employeeOfTheMonthContainer = ({ userId, company }) =>
          this.ngrxComposeService.createContainer(
            loadEmployeeOfTheMonth({ userId }),
            [
              this.employeeDetailsContainer({ company }),
            ]
          );
      }
    }
  • Start using it

    export class MyComponent implements OnInit {
    
      constructor(
        private readonly ngrxCmposeService: NgrxComposeService,
        private readonly employeeContainer: EmployeeContainer,
      ) {}
    
      ngOnInit(): void {
        this.ngrxCmposeService.dispatch(
          this.employeeContainer.employeeOfTheMonth({
            userId: '1337',
            company: 'E Corp'
          }),
        );
      }
    
    }

Usage and API

TODO

0.1.0

4 years ago

0.0.5

4 years ago

0.0.6

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago