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

[.38] Returning an Observable from EventEmitter #4521

Closed
ericmdantas opened this issue Oct 5, 2015 · 2 comments
Closed

[.38] Returning an Observable from EventEmitter #4521

ericmdantas opened this issue Oct 5, 2015 · 2 comments

Comments

@ericmdantas
Copy link
Contributor

Looks like we've got a problem with EventEmitters now. Either that or I'm missing something.

Here is the plnkr with the situation: http://plnkr.co/edit/9w5nzAuMkE1BHoTo2GxN?p=preview

Basically, we can't return an observable anymore when using toRx() see the change here.

We can return an observable with _subject, though. But it just doesn't feel right.

Does anyone have any word on it? Should I still be using EventEmitter for that kind of situation or just switch to Rx's Observables?

Here's the full code:

import {Component, View, EventEmitter, OnInit, bootstrap} from 'angular2/angular2';

class SomethingService {
  _ee: EventEmitter = new EventEmitter();

  fireStuff() {
    setTimeout(() => {
      this._ee.next('fire!');
    }, 1000);

    //return this._ee.toRx(); - doesn't work anymore
    return this._ee._subject; // silly work around
  }
}

@Component({
    selector: 'hello',
    viewBindings: [SomethingService]
})
@View({
    template: `
      <h3>hello - uncomment line 11 and comment line 12 to see the error</h3>
      <button type="button"
            (click)="fire()">btn</button>
    <pre [text-content]="f"></pre>
    `
})
export class Hello implements OnInit {
  f: string;

  constructor(private _ss: SomethingService) {

  }

  onInit() {
    console.log('hello init');
  }

  fire() {
    this.f = "loading";

    this._ss
        .fireStuff()
        .subscribe((info) => {
          this.f = info;
        });
  }
}


bootstrap(Hello);

Old issue: #3580

cc: @ericmartinezr @robwormald @pkozlowski-opensource

@IgorMinar IgorMinar added this to the alpha-39 milestone Oct 5, 2015
robwormald added a commit to robwormald/angular that referenced this issue Oct 6, 2015
this was broken in the original great RxNext migration.
fixes angular#4521
@robwormald
Copy link
Contributor

fixed in #4540

@naomiblack naomiblack modified the milestones: alpha-39, alpha-40 Oct 6, 2015
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants