15.0.0-beta.0 (2022-11-03)
Features
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]);
AFTER:
provideEffects
expects the effects as a spreaded array as argument.
// single effect
provideEffects(MyEffect);
// multiple effects
provideEffects(MyEffect, MySecondEffect);
<a name="14.3.2"></a>