Closed hvqthong closed 7 years ago
Good suggestion. I'll work on that, once I'm back from vacation.
@KeitaElric I'm familiar with the basic concept about observables but not too much with the specifics. I wonder what types of observables would you like to be supported. Could you maybe provide a specific use case scenario? That would be super helpful!
It already works if you do it like this:
initObservable() {
// const obs = FAKE_FACT.initObservable();
const obs = new Observable(observer => {
setTimeout(() => {
observer.next(1);
}, 1000);
setTimeout(() => {
observer.next(2);
}, 2000);
setTimeout(() => {
observer.next(3);
}, 3000);
setTimeout(() => {
observer.complete();
}, 4000);
});
this.obsVal = 'INITIALIZED';
this.observableItem = obs
.forEach((val) => {
this.obsVal = val;
})
.then(() => {
console.log('OBS COMPLETED');
this.obsVal = 'COMPLETE';
});
}
<button class="btn btn-raised"
(click)="initObservable()"
[promiseBtn]="observableItem">Observable {{ obsVal }}
</button>
As long as there is a then, you should be fine.
Thanks to @maxkorz this should work with any kind of observable now.
Can you guys support for Observable? Thanks 😀