Create observable from component method, that is called as an event handler
<p>I have a component, that looks like this:</p>

<pre><code>@Component({
    template: `
    ...
    &lt;child-component (childEvent)="onChildEvent()"&gt;&lt;/child-component&gt;
`
})
export class ParentComponent {
    onChildEvent() {
        ...
    }
}
</code></pre>

<p>I want to turn the calls to the <code>onChildFinished</code> method into an observable sequence.</p>

<p>Now, if the method in question was a handler for some "native" DOM event such as click, blur, etc, I would've used <code>Observable.fromEvent</code>, but in this case this does not seem to be applicable (as there is no native event involved).</p>

<p>The only thing that comes to mind is something like this:</p>

<pre><code>@Component({
    template: `
    ...
    &lt;child-component (childEvent)="onChildEvent()"&gt;&lt;/child-component&gt;
`
})
export class ParentComponent implements OnInit, OnDestroy {
    private childEventStream: Observable&lt;void&gt;;

    // I am not sure, what is the type of this,
    // seems like an internal RxJS thing
    private observer: any; 

    onChildEvent() {
        this.observer.next();
    }

    ngOnInit() {
        this.childFinishedStream = Observable.create(
            observer =&gt; this.observer = observer;
        );
    }

    ngOnDestroy() {
        this.observer.completed();
    }
}
</code></pre>

<p>It seems, that there must be a better way, since this has to be quite tedious to maintain if there are multiple handlers involved.</p>