Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(effects): change the signature of provideEffect #3587

Merged
merged 1 commit into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions modules/effects/spec/provide_effects.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ describe('provideEffects', () => {
},
provideStore({}).ɵproviders,
// provide effects twice
provideEffects([]).ɵproviders,
provideEffects([]).ɵproviders,
provideEffects().ɵproviders,
provideEffects().ɵproviders,
],
});

Expand All @@ -50,8 +50,8 @@ describe('provideEffects', () => {
},
provideStore().ɵproviders,
// provide effects twice
provideEffects([]).ɵproviders,
provideEffects([]).ɵproviders,
provideEffects().ɵproviders,
provideEffects().ɵproviders,
],
});

Expand All @@ -63,7 +63,7 @@ describe('provideEffects', () => {
it('throws an error when store is not provided', () => {
TestBed.configureTestingModule({
// provide only effects
providers: [provideEffects([TestEffects]).ɵproviders],
providers: [provideEffects(TestEffects).ɵproviders],
});

expect(() => TestBed.inject(TestEffects)).toThrowError();
Expand All @@ -73,7 +73,7 @@ describe('provideEffects', () => {
TestBed.configureTestingModule({
providers: [
provideStore().ɵproviders,
provideEffects([TestEffects]).ɵproviders,
provideEffects(TestEffects).ɵproviders,
],
});

Expand All @@ -91,7 +91,7 @@ describe('provideEffects', () => {
it('runs provided effects after root state registration', (done) => {
TestBed.configureTestingModule({
providers: [
provideEffects([TestEffects]).ɵproviders,
provideEffects(TestEffects).ɵproviders,
// provide store after effects
provideStore({ [rootSliceKey]: createReducer('ngrx') }).ɵproviders,
],
Expand All @@ -114,7 +114,7 @@ describe('provideEffects', () => {
TestBed.configureTestingModule({
providers: [
provideStore().ɵproviders,
provideEffects([TestEffects]).ɵproviders,
provideEffects(TestEffects).ɵproviders,
// provide feature state after effects
provideState(featureSliceKey, createReducer('effects')).ɵproviders,
],
Expand Down
8 changes: 5 additions & 3 deletions modules/effects/src/provide_effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { rootEffectsInit as effectsInit } from './effects_actions';
*
* ```ts
* bootstrapApplication(AppComponent, {
* providers: [provideEffects([RouterEffects])],
* providers: [provideEffects(RouterEffects]],
* });
* ```
*
Expand All @@ -34,7 +34,7 @@ import { rootEffectsInit as effectsInit } from './effects_actions';
* const booksRoutes: Route[] = [
* {
* path: '',
* providers: [provideEffects([BooksApiEffects])],
* providers: [provideEffects(BooksApiEffects)],
* children: [
* { path: '', component: BookListComponent },
* { path: ':id', component: BookDetailsComponent },
Expand All @@ -43,7 +43,9 @@ import { rootEffectsInit as effectsInit } from './effects_actions';
* ];
* ```
*/
export function provideEffects(effects: Type<unknown>[]): EnvironmentProviders {
export function provideEffects(
...effects: Type<unknown>[]
): EnvironmentProviders {
return {
ɵproviders: [
effects,
Expand Down
2 changes: 1 addition & 1 deletion projects/standalone-app/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ bootstrapApplication(AppComponent, {
name: 'NgRx Standalone App',
}),
provideRouterStore(),
provideEffects([AppEffects]),
provideEffects(AppEffects),
],
});