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

Operator above EnterZone never gets executed #17

Open
colinskow opened this issue Jun 1, 2017 · 0 comments
Open

Operator above EnterZone never gets executed #17

colinskow opened this issue Jun 1, 2017 · 0 comments

Comments

@colinskow
Copy link

I am using EnterZone with @ngrx/effects in order to get Angular to do change detection upon receiving data from Electron IPC. I noticed the operator immediately above .enterZone() is not executed. (Using latest rxjs v5.4.0.)

Here is my code:

import { Injectable, NgZone } from '@angular/core';
import { Actions, Effect, toPayload } from '@ngrx/effects';
import { Action } from '@ngrx/store';
import { Observable } from 'rxjs/Observable';
import '@ngrx/core/add/operator/enterZone';
import rxIpc from 'rx-ipc-electron/lib/renderer';
import * as player from './player.actions';

@Injectable()
export class PlayerEffects {

  @Effect()
  public openFile$: Observable<Action> = this.actions$
    .ofType(player.LOAD_MEDIA_DIALOG)
    .switchMap(() => rxIpc.runCommand('open-media-file', null))
      .switchMap(files => {
        if (!files) {
          return Observable.empty();
        }
        return Observable.of(new player.SetSourceAction(files[0]));
      })
      .do(() => console.log('THIS IS NEVER EXECUTED.'))
      .enterZone(this.zone);

  constructor(
    private zone: NgZone,
    private actions$: Actions
  ) { }

}

I believe the easiest fix is to directly fork the rxjs do operator and wrap all three subscriber callbacks in the zone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant