Socket
Socket
Sign inDemoInstall

@ngrx/component-store

Package Overview
Dependencies
4
Maintainers
4
Versions
74
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @ngrx/component-store

Reactive store for component state


Version published
Weekly downloads
187K
increased by3.14%
Maintainers
4
Created
Weekly downloads
 

Changelog

Source

15.0.0-beta.0 (2022-11-03)

Features

  • component: add migration for replacing ReactiveComponentModule (#3506) (49c6cf3), closes #3491
  • component: handle observable dictionaries (#3602) (42efccb), closes #3545
  • component: remove ReactiveComponentModule (#3643) (4bdf345), closes #3623
  • component-store: Add SelectorObject to select (#3629) (f8d0241), closes #3632 #3631
  • effects: change the signature of provideEffect (#3587) (899afe7)
  • effects: migration for provideEffects argument (#3601) (f7dfeab)
  • effects: remove @Effect decorator (#3634) (96c5bdd), closes #3617
  • eslint-plugin: remove rules using @Effect (#3635) (5f74e61)
  • schematics: drop support for TypeScript <4.8 (#3631) (b9c1ab6)
  • store: make reducers arg of StoreModule.forRoot optional (#3632) (e5177aa)
  • store: strict projector for selectors with props (#3640) (351459f), closes #3571
  • store: strict projectors (#3581) (43198a2), closes #3571

BREAKING CHANGES

  • component: ReactiveComponentModule is removed in favor of LetModule and PushModule.

BEFORE:

import { ReactiveComponentModule } from '@ngrx/component';

@NgModule({
  imports: [
    // ... other imports
    ReactiveComponentModule,
  ],
})
export class MyFeatureModule {}

AFTER:

import { LetModule, PushModule } from '@ngrx/component';

@NgModule({
  imports: [
    // ... other imports
    LetModule,
    PushModule,
  ],
})
export class MyFeatureModule {}
  • store: The projector method has become strict

BEFORE:

You could pass any arguments to the projector method

const selector = createSelector( selectString, // returning a string selectNumber, // returning a number (s, n, prefix: string) => { return prefix + s.repeat(n); } )

// you could pass any argument selector.projector(1, 'a', true);

AFTER:

const selector = createSelector( selectString, // returning a string selectNumber, // returning a number (s, n, prefix: string) => { return prefix + s.repeat(n); } )

// this throws selector.projector(1, 'a', true); // this does not throw because the arguments have the correct type selector.projector(1, 'a', 'prefix');

  • store: The projector function on the selector is type-safe by default.

BEFORE:

The projector is not type-safe by default, allowing for potential mismatch types in the projector function.

const mySelector = createSelector(
  () => 'one',
  () => 2,
  (one, two) => 3
);

mySelector.projector(); // <- type is projector(...args: any[]): number

AFTER:

The projector is strict by default, but can be bypassed with an any generic parameter.

const mySelector = createSelector(
  () => 'one',
  () => 2,
  (one, two) => 3
);

mySelector.projector(); // <- Results in type error. Type is projector(s1: string, s2: number): number

To retain previous behavior

const mySelector = createSelector(
  () => 'one',
  () => 2,
  (one, two) => 3
)(mySelector.projector as any)();
  • effects: The @Effect decorator is removed

BEFORE:

Defining an effect is done with @Effect

@Effect() data$ = this.actions$.pipe();

AFTER:

Defining an effect is done with createEffect

data$ = createEffect(() => this.actions$.pipe());

  • effects: The signature of provideEffects is changed to expect a spreaded array of effects.

BEFORE:

provideEffects expecteded the effects to be passed as an array.

// single effect
provideEffects([MyEffect])

// multiple effects
provideEffects([MyEffect, MySecondEffect])
```ts

AFTER:

`provideEffects` expects the effects as a spreaded array as argument.

```ts
// single effect
provideEffects(MyEffect)

// multiple effects
provideEffects(MyEffect, MySecondEffect)
```ts



<a name="14.3.2"></a>

Readme

Source

@ngrx/component-store

The sources for this package are in the main NgRx repo. Please file issues and pull requests against that repo.

Keywords

FAQs

Last updated on 03 Nov 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc