nolancaster / angular2-actioncable

Integrate ActionCable with Angular2+
25 stars 16 forks source link

sink._addParentTeardownLogic is not a function when using pipe() #12

Open rileypb opened 4 years ago

rileypb commented 4 years ago

In angular2-actioncable 6.0.2 and rxjs 6.3.3: Piping the connected() Observable through other operators seems to break.

Here's my app.component.ts:

import { Component, OnInit, OnDestroy } from '@angular/core';
import { first, map } from 'rxjs/operators';
import { ActionCableService, Channel } from 'angular2-actioncable';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
  title = 'sb-angular';

  constructor(private actionCableService: ActionCableService) {}

  ngOnInit() {
    var channel = this.actionCableService
      .cable('ws://localhost:3000/cable')
      .channel('SyncChannel');

    channel.connected().pipe(first()).subscribe(x => console.log(x));
  }

}

This causes the error:

AppComponent_Host.ngfactory.js? [sm]:1 ERROR TypeError: sink._addParentTeardownLogic is not a function
    at Subject.push../node_modules/angular2-actioncable/angular2-actioncable.es5.js.Observable.subscribe (angular2-actioncable.es5.js:528)
    at Observable.push../node_modules/angular2-actioncable/angular2-actioncable.es5.js.Observable._subscribe (angular2-actioncable.es5.js:574)
    at Observable.push../node_modules/angular2-actioncable/angular2-actioncable.es5.js.Observable.subscribe (angular2-actioncable.es5.js:529)
    at FirstOperator.push../node_modules/rxjs/_esm5/operators/first.js.FirstOperator.call (first.js:71)
    at Observable.push../node_modules/angular2-actioncable/angular2-actioncable.es5.js.Observable.subscribe (angular2-actioncable.es5.js:525)
    at AppComponent.push../src/app/app.component.ts.AppComponent.ngOnInit (app.component.ts:22)
    at checkAndUpdateDirectiveInline (core.js:12411)
    at checkAndUpdateNodeInline (core.js:13935)
    at checkAndUpdateNode (core.js:13878)
    at debugCheckAndUpdateNode (core.js:14771)

I cannot reproduce this error when piping other base observables; it only happens when I use observables from angular2-actioncable.

nolancaster commented 4 years ago

Something must be going on within rxjs. I'm not really sure what to do about that at the moment, but I do plan on trying to upgrade this plugin eventually to work with newer versions of rxjs without (hopefully) breaking the auto-unsubscribe feature.