NGRX / PLATFORM
Predictable Reactive State Management for Enterprise
Applications
A B O U T M E
{
"name": "Ilia Idakiev",
"experience": [
"Developer / Manager / Owner @ HNS",
"Lecturer in 'Advanced JS' @ FMI",
"Contractor / Consultant",
"2 Angular Courses @ HB (2016 - 2017)",
"JavaScript Courses"
],
"involvedIn": [
"SofiaJS", "BeerJS", "Angular Sofia"
]
}
TYPES OF DATA
➤ Application State
➤ UI State
➤ Domain-specific Data
SMALL ANGULAR APPLICATION EXAMPLE
One week later ....
MEDIUM ANGULAR APPLICATION EXAMPLE
This complexity is difficult to handle as we're mixing two
concepts that are very hard for the human mind to reason
about: mutation and asynchronicity.
REDUX
REDUX CONCEPTS
➤ Single source of truth
➤ State is read-only
➤ Changes are made with pure functions
ANGULAR REDUX EXAMPLE
Separation of concerns (SoC) is a design principle for
separating a computer program into distinct sections, such
that each section addresses a separate concern.
ANGULAR REDUX EXAMPLE
NGRX
NgRx is suite of libraries that empower Angular developers to be
more effective at building large projects.
NGRX / PLATFORM
➤ @ngrx/store - RxJS powered state management for Angular applications, inspired
by Redux
➤ @ngrx/effects - Side Effect model for @ngrx/store to model event sources as
actions.
➤ @ngrx/router-store - Bindings to connect the Angular Router to @ngrx/store
➤ @ngrx/store-devtools - Store instrumentation that enables a powerful time-
travelling debugger.
➤ @ngrx/entity - Entity State adapter for managing record collections.
NGRX 4
➤ Out of the box support for lazy loading new reducers.
➤ Improved testing using marbles.

(https://github.com/ReactiveX/rxjs/blob/master/doc/writing-marble-tests.md)
➤ Redesigned router integration so resolvers and guards can access the new
state.
Let's separate the side-effects ...
ANGULAR REDUX EXAMPLE
https://github.com/ngrx/platform/tree/master/example-app
LIVE CODING TIME
ANGULAR / NX
ANGULAR / NX
➤ Open source toolkit.
➤ It is designed to help companies build enterprise grade Angular applications. Usually
this companies have several teams building multiple apps using multiple shared libs.
➤ It provides an opinionated approach to application project structure and patterns
using angular/schematics.
WHAT IS ANGULAR / NX
➤ nrwl/schematics - Code generators that can be used to create files and projects
➤ @nrwl/nx - An Angular library of classes and functions that can be imported
DEMO
FOLLOW ME
GitHub > https://github.com/iliaidakiev (/slides/ - list of future and past events)
Twitter > @ilia_idakiev
THANK YOU!

Predictable reactive state management for enterprise apps using NGRX/platform

  • 1.
    NGRX / PLATFORM PredictableReactive State Management for Enterprise Applications
  • 2.
    A B OU T M E { "name": "Ilia Idakiev", "experience": [ "Developer / Manager / Owner @ HNS", "Lecturer in 'Advanced JS' @ FMI", "Contractor / Consultant", "2 Angular Courses @ HB (2016 - 2017)", "JavaScript Courses" ], "involvedIn": [ "SofiaJS", "BeerJS", "Angular Sofia" ] }
  • 3.
    TYPES OF DATA ➤Application State ➤ UI State ➤ Domain-specific Data
  • 4.
  • 5.
  • 6.
  • 7.
    This complexity isdifficult to handle as we're mixing two concepts that are very hard for the human mind to reason about: mutation and asynchronicity.
  • 8.
  • 9.
    REDUX CONCEPTS ➤ Singlesource of truth ➤ State is read-only ➤ Changes are made with pure functions
  • 10.
  • 11.
    Separation of concerns(SoC) is a design principle for separating a computer program into distinct sections, such that each section addresses a separate concern.
  • 12.
  • 13.
    NGRX NgRx is suiteof libraries that empower Angular developers to be more effective at building large projects.
  • 14.
    NGRX / PLATFORM ➤@ngrx/store - RxJS powered state management for Angular applications, inspired by Redux ➤ @ngrx/effects - Side Effect model for @ngrx/store to model event sources as actions. ➤ @ngrx/router-store - Bindings to connect the Angular Router to @ngrx/store ➤ @ngrx/store-devtools - Store instrumentation that enables a powerful time- travelling debugger. ➤ @ngrx/entity - Entity State adapter for managing record collections.
  • 15.
    NGRX 4 ➤ Outof the box support for lazy loading new reducers. ➤ Improved testing using marbles.
 (https://github.com/ReactiveX/rxjs/blob/master/doc/writing-marble-tests.md) ➤ Redesigned router integration so resolvers and guards can access the new state.
  • 16.
    Let's separate theside-effects ...
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
    ANGULAR / NX ➤Open source toolkit. ➤ It is designed to help companies build enterprise grade Angular applications. Usually this companies have several teams building multiple apps using multiple shared libs. ➤ It provides an opinionated approach to application project structure and patterns using angular/schematics.
  • 22.
    WHAT IS ANGULAR/ NX ➤ nrwl/schematics - Code generators that can be used to create files and projects ➤ @nrwl/nx - An Angular library of classes and functions that can be imported
  • 23.
  • 24.
    FOLLOW ME GitHub >https://github.com/iliaidakiev (/slides/ - list of future and past events) Twitter > @ilia_idakiev
  • 25.