Gathering detailed insights and metrics for @rx-signals/angular-provider
Gathering detailed insights and metrics for @rx-signals/angular-provider
An Angular module to provide the rx-signals store
npm install @rx-signals/angular-provider
Typescript
Module System
Node Version
NPM Version
69.5
Supply Chain
84.1
Quality
75.8
Maintenance
100
Vulnerability
98.9
License
TypeScript (90.36%)
JavaScript (9.64%)
Total Downloads
2,194
Last Day
2
Last Week
10
Last Month
39
Last Year
167
27 Commits
1 Watching
1 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
3.0.0-rc14
Package Id
@rx-signals/angular-provider@3.0.0-rc14
Unpacked Size
148.62 kB
Size
26.39 kB
File Count
34
NPM Version
8.19.2
Node Version
18.12.1
Publised On
24 Feb 2023
Cumulative downloads
Total Downloads
Last day
-33.3%
2
Compared to previous day
Last week
42.9%
10
Compared to previous week
Last month
129.4%
39
Compared to previous month
Last year
-86.3%
167
Compared to previous year
1
3
You can use this lib for an opinionated rx-signals integration into your Angular application.
It features Angular providers for rx-signals store and/or child-stores.
In addition, it features some pipes and directives to work with validation and optional-lenses.
npm install --save @rx-signals/angular-provider@3.0.0-rc14
If you have not yet installed the rx-signals store, please see @rx-signals/store documentation on how to install the latest 3.x version of that peer-dependency.
In your bootstrapApplication
, just use provideStore()
.
This will provide a Store
singleton everywhere (so even lazy-loaded routes will receive the same store instance).
If you have functions performing setup with the store ((store: Store) => void
), you can pass 0 to N of those setup-functions as arguments to provideStore()
.
If you're really sure a child-route should use its own child-store, you can do so by using provideChildStore()
in the corresponding routes providers array.
Make sure to read the documentation on child-stores.
Also, be aware that store-lifecycles might be a better option for your use-case.
In the topmost module that should use the store (AppModule, SharedModule, CoreModule, or whatever it is for you), you can just import RxSignalsStoreModule
.
This will provide a Store
singleton everywhere (so even lazy-loaded feature-modules will receive the same instance).
Instead, if you have functions performing setup with the store ((store: Store) => void
), you can use RxSignalsStoreModule.withRootStore()
, passing as many of those setup-functions as arguments as you like.
You can also use RxSignalsStoreModule.withRootStore()
in your feature-modules (whether lazy or not) to pass corresponding setup-functions of those feature-modules.
You might be used to modules that come with
forRoot()
andforFeature()
functions. These names make no sense in case of the RxSignalsStoreModule, because the standard-case is to use a single store-instance in all your modules and thus, all these modules should callwithRootStore()
. See the next section on use-cases forwithChildStore()
.
If you are really sure that you have a feature-module where you want to use a child-store (derived from the root-store that you get with RxSignalsStoreModule
or RxSignalsStoreModule.withRootStore()
), then you can do so by importing RxSignalsStoreModule.withChildStore()
.
Make sure to read the documentation on child-stores.
Also, be aware that store-lifecycles might be a better option for your use-case.
If you read about the concept about side-effect-isolation with the store, you know that the only side-effect that the functions passed to RxSignalsStoreModule.withRootStore()
and/or RxSignalsStoreModule.withChildStore()
are allowed to do is calling methods of the passed store.
All the signals being setup in this process should be free of side-effects (allowing you to call the setup-functions in your tests without any need of mockup).
Consequently, the side-effects must be injected to the store by corresponding calls to store.addEffect
.
In your unit-tests, you would then just mock the effects themselves by store.addEffect(effectId, () => someMockupReturn)
(so no need to mock anything else).
No vulnerabilities found.
No security vulnerabilities found.