Skip to content

Operator above EnterZone never gets executed #17

@colinskow

Description

@colinskow

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions