Skip to content

Schematics: Default effect leads to an endless loop #1573

@fmalcher

Description

@fmalcher

The command ng generate feature does create an effects class with the following effect (example):

@Effect()
loadBooks$ = this.actions$.pipe(ofType(BookActionTypes.LoadBooks));

(see https://github.com/ngrx/platform/blob/master/modules/schematics/src/effect/files/__name%40dasherize%40if-flat__/__name%40dasherize__.effects.ts#L24)

If left untouched, this will lead to a loop of death as soon as the first LoadBooks action is being dispatched.

Possible solutions

  • Comment out the @Effect() decorator by default
  • don't provide a default effect after creation
  • set { dispatch: false }

I don't like any of them – but I ran into that the infinite loop problem multiple times now 😆
Will prepare a PR if there is consensus about how we can solve this.

I would be willing to submit a PR to fix this issue

[x] Yes (Assistance is provided if you need help submitting a pull request)
[ ] No

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions