platform icon indicating copy to clipboard operation
platform copied to clipboard

[Ivy] 9.0.0-beta.0 - Life Cycle Effects Hook loses context

Open jerryorta opened this issue 6 years ago • 5 comments

NgRX 9.0.0-beta.0 , Angular 9.0.0, Node 12.3.0:

The lifecycle ngrxOnInitEffects is broken - it loses the context of "this" so code inside that hook doesn't understand the class properties, methods, constructor injections -- Rolling back to 8.6.0 works.

Other information:

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

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

jerryorta avatar Feb 12 '20 15:02 jerryorta

Experiencing the same issue. This can be reproduced by adding an ngrxOnInitEffects to the NgRx example-app repo.

class AuthEffects implements OnInitEffects {
  ngrxOnInitEffects(): Action {
    return { type: '[Auth]: Auth Init' };
  }

initAuth$ = createEffect(() =>
    this.actions$.pipe(
      ofType('[Auth]: Auth Init'),
      tap(action => {
        console.log('test ngrxOnInitEffects');
      })
    ),
  { dispatch: false });
}

GuateDevIO avatar Feb 12 '20 16:02 GuateDevIO

I haven't verified if this is the culprit, but there has been a change to OnInit in the v9 release - https://github.com/ngrx/platform/commit/a528320dc05fbe91959f91870535b1bd7487d142

timdeschryver avatar Feb 12 '20 17:02 timdeschryver

@timdeschryver @brandonroberts when is the release date of NGRX 9 stable?

Wildhammer avatar Feb 14 '20 18:02 Wildhammer

No specific release date yet, but soon-ish.

brandonroberts avatar Feb 14 '20 21:02 brandonroberts

@jerryorta-dev fyi, this wasn't the cause of Ivy - see #2386 for more info

timdeschryver avatar Feb 15 '20 21:02 timdeschryver