npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@rx-signals/angular-provider

v3.0.0-rc14

Published

Angular provider for @rx-signals/store

Downloads

19

Readme

@rx-signals/angular-provider

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.

Installation

npm install --save @rx-signals/[email protected]

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.

License

MIT

Usage

Modern usage without NgModule

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().

Optionally using child-stores on child-routes

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.

Usage with classic NgModule

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() and forFeature() 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 call withRootStore(). See the next section on use-cases for withChildStore().

Optionally using child-stores

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.

Setup effects

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).