17.4.0 • Published 12 days ago

ngssm-store v17.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
12 days ago

State management

This is a simple custom adaptation and implementation of the redux pattern.

  graph TB;
    B["Store (State manager)"]
    C[/Actions queue/]
    A["State Observers: <br/> <ul> <li>Components</li> <li>Directives</li> <li>Guards</li></ul>"]  
    
    subgraph G[Action processors]
        D[<b>Reducers</b> <br/> Updates state synchronously taking state immutability into account]
        E[<b>Effects</b> <br/> No update of the state. <br/> Call to remote services <br/> Actions dispatch...]
    end

    C --- B
    A -- Dispatch actions --> B
    B -- Publish state --> A
    B -- Apply action on state --> D
    B -- Process action --> E
    D -- Updated state --> B
    E -- Dispatch actions --> B

    style A text-align:left
    style C fill:lightgray

Store Overview

Action dispatching

  sequenceDiagram
    actor O as Component/Effect
    participant S as Store
    participant Q as Actions Queue
    participant E as Event loop
    O->>S: dispatch action
    S->>Q: add action
    S->>E: add message to process next action

An action dispatched by a component or an effect is not processed immediately. The store uses the setTimeout function to process "later" the action.

Action processing

  sequenceDiagram
    participant L as Event loop
    participant S as Store
    participant Q as Actions Queue
    actor O as State Observer
    participant R as Reducer
    participant E as Effect
    L->>S: doProcessNextAction
    S->>Q: get next available action
    alt There is an action to process
      loop For all registered reducers for the current sction
        S->>R: update state
      end

      S->>O: publish new state

      loop For all registered effects for the current action
        S->>E: process action
      end

      S->>L: add message to process next action
    end

Dependencies

  • angular: the library uses the dependency injection system provided by angular,
  • rxjs: the publish/subscribe pattern is implemented with rxjs,
  • immutability-helper: used by the reducers to update safely the state

The state must be immutable. But, to simplify the implementation, it is the responsibility of the user to be sure that the state instance is never updated.

  • schematics: schematics are provided to create feature state, components, reducers, effects, actions...
  • mermaid.js for the documentation.

Schematics

See ngssm-schematics for schematics used to create feature state, action, reducer, effect...

17.4.0

12 days ago

17.3.2

2 months ago

17.3.1

2 months ago

17.3.0

2 months ago

17.2.1

2 months ago

17.2.0

3 months ago

17.1.2

3 months ago

17.1.1

4 months ago

17.1.0

4 months ago

17.0.7

5 months ago

17.0.6

5 months ago

16.2.5

6 months ago

17.0.3

6 months ago

17.0.2

6 months ago

17.0.5

6 months ago

17.0.4

6 months ago

17.0.1

6 months ago

17.0.0

6 months ago

16.2.4

7 months ago

16.2.3

7 months ago

16.2.2

7 months ago

16.2.1

8 months ago

16.1.10

10 months ago

16.1.12

10 months ago

16.1.11

10 months ago

16.1.9

11 months ago

16.1.8

11 months ago

16.1.7

11 months ago

16.1.6

11 months ago

16.1.1

11 months ago

16.1.0

11 months ago

16.1.5

11 months ago

16.1.4

11 months ago

16.1.3

11 months ago

16.1.2

11 months ago

16.2.0

9 months ago

16.0.2

1 year ago

16.0.1

1 year ago

16.0.3

12 months ago

15.3.14

1 year ago

15.3.9

1 year ago

15.3.11

1 year ago

15.3.10

1 year ago

15.3.13

1 year ago

15.3.12

1 year ago

16.0.0

1 year ago

15.2.0

1 year ago

15.1.1

1 year ago

15.2.1

1 year ago

15.1.2

1 year ago

15.3.0

1 year ago

15.1.0

1 year ago

15.3.2

1 year ago

15.2.4

1 year ago

15.3.1

1 year ago

15.2.5

1 year ago

15.3.4

1 year ago

15.2.2

1 year ago

15.3.3

1 year ago

15.2.3

1 year ago

15.3.6

1 year ago

15.2.8

1 year ago

15.3.5

1 year ago

15.2.9

1 year ago

15.3.8

1 year ago

15.2.6

1 year ago

15.3.7

1 year ago

15.2.7

1 year ago

15.2.11

1 year ago

15.2.12

1 year ago

15.2.10

1 year ago

15.0.2

1 year ago

15.0.3

1 year ago

15.0.0

1 year ago

15.0.1

1 year ago

15.0.4

1 year ago

14.2.0

2 years ago

14.2.1

2 years ago

14.2.2

2 years ago

14.2.3

1 year ago

14.1.4

2 years ago

14.1.5

2 years ago

14.1.3

2 years ago

14.1.2

2 years ago

14.1.1

2 years ago

14.1.0

2 years ago

14.0.2

2 years ago

14.0.1

2 years ago

14.0.0

2 years ago