briebug / ngrx-auto-entity

NgRx Auto-Entity: Simplifying Reactive State
https://briebug.gitbook.io/ngrx-auto-entity/
Other
66 stars 12 forks source link

feat: action factory functions #164

Closed jrista closed 3 years ago

jrista commented 3 years ago

This PR adds action factories, conforming to NgRx 8+ types that support createAction, createReducer, on, and ofType for createEffect type effects. New action factories build on top of the existing auto-entity action types to maintain compatibility with the existing auto-entity meta reducer, operators/effects, entity service, etc. This also maintains backwards compatibility with existing NgRx Auto-Entity users, allowing any current users to migrate to the new model at will and over time.

This PR also introduces the concept of "create on use" to the state builders. When calling buildState, to date this would pre-create ALL dynamic functionality, including selectors, a facade, initial state, etc. The actions builder will instead only create the actions that are actually accessed on the object returned from buildState/buildFeatureState. Each action created is cached on a property attached to the entity model's type (class). This "create on use" approach will ultimately be backported to all of the other code generated by buildState/buildFeatureState so that only the features used for any given entity are actually generated.

This means if a particular application never uses a given action factory, it will never be created. In the future, it will also mean that if a particular application never uses facades, they will not be created. Never uses certain selectors for entities, they will never be created. Etc.

Change log:

+ Add factory creation utilities
+ Add load factories
+ Add load all factories
+ Add load many factories
+ Add load page factories
+ Add load range factories

+ Add unit tests for action factory utils
+ Add unit tests for load action factories

+ Add action map interface
+ Add action map builder
+ Update state builder functions to add action builders

+ Add CUURD factories
* Update action map builder with  CUURD factories

+ Add clear factory
+ Add selection factories
+ Add deselection factories
+ Add edit factories
* Update factory utils to separate correlationId to own interface
* Update action map builder with new factories

* Include action map builder in public interface

Issue #76