{"action":"closed","issue":{"url":"https://api.github.com/repos/angular/angular/issues/3580","labels_url":"https://api.github.com/repos/angular/angular/issues/3580/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular/issues/3580/comments","events_url":"https://api.github.com/repos/angular/angular/issues/3580/events","html_url":"https://github.com/angular/angular/issues/3580","id":100212363,"number":3580,"title":"[Question] Using EventEmitter to manipulate data and return an Observable.","user":{"login":"ericmdantas","id":7040162,"avatar_url":"https://avatars.githubusercontent.com/u/7040162?v=3","gravatar_id":"","url":"https://api.github.com/users/ericmdantas","html_url":"https://github.com/ericmdantas","followers_url":"https://api.github.com/users/ericmdantas/followers","following_url":"https://api.github.com/users/ericmdantas/following{/other_user}","gists_url":"https://api.github.com/users/ericmdantas/gists{/gist_id}","starred_url":"https://api.github.com/users/ericmdantas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericmdantas/subscriptions","organizations_url":"https://api.github.com/users/ericmdantas/orgs","repos_url":"https://api.github.com/users/ericmdantas/repos","events_url":"https://api.github.com/users/ericmdantas/events{/privacy}","received_events_url":"https://api.github.com/users/ericmdantas/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-08-11T02:32:06Z","updated_at":"2015-08-12T21:27:00Z","closed_at":"2015-08-12T21:27:00Z","body":"I have asked this in the gitter room, but there were no responses, so I thought I might ask this here.\r\n\r\nIt looks like if we want to work with Rx.Observables, we'll have to use the EventEmitter class.\r\n\r\nI was wondering how to do the following:\r\n\r\n- My component calls a service passing something by parameter;\r\n- My service modifies the parameter;\r\n- My service returns an Observables so that my Component can observe and subscribe to it;\r\n\r\n\r\nIf I am using Rx.Observable (by importing it directly - ```import * as Rx from 'rx'```), I can do the following:\r\n```ts\r\n// MyService\r\n\r\nexport class MyService {\r\n    static doSomething(something: Object):Rx.Observable {\r\n          return Rx.Observable.create(o => {\r\n                  something.createdAt = Date.now();\r\n                  o.onNext(something);\r\n                  o.onCompleted();\r\n          })\r\n    }\r\n}\r\n```\r\n\r\nAnd then in my component:\r\n\r\n```ts\r\n// MyComponent\r\n\r\nclass MyComponent {\r\n     doSomethingHandler(something:Object):void {\r\n           MyService.doSomething(something).subscribe(info => console.log(info));\r\n     } \r\n}\r\n```\r\n\r\nSo, that'd work.\r\n\r\nBut how to do it with the EventEmitter wrapper? \r\n\r\nI saw it returns a ```Subject``` instead of an ```Observable```, and it looks like I'd have to pass callbacks left and right to make it work - but I'd like to have the logic separated - having the component to only call the service, and this one would do the heavy work, returning something already manipulated to the component."}}