[angular 2.4.5]
I tried and it seems to work like an EventEmitter:
My component from outside:
<split (visibleTransitionEnd)="log($event)"></split>
Inside the component:
@Output() visibleTransitionEnd: Observable<string> observer: Observer; constructor() { const myObs = new Observable(observer => this.observer = observer); this.visibleTransitionEnd = myObs .map(x => '> ' + x + ' <') .debounceTime(20) .do(() => console.log('here we are!')); }
Then I can call inside component:
// needed condition because if nobody subscribe 'visibleTransitionEnd' > no observer! if(this.observer) this.observer.next('test');
I like this because there's no subscription inside my component.
But is it a bad way to achieve this? What's the risk/wrong?
Is it better to use a Subject
?