let observable = new Observable((observer) => {
observer.next();
setTimeout(() => {
observer.complete();
}, 1000);
});
let isComplete = false;
let counter = 0;
observable.subscribe({
next() {
while (!isComplete) {
console.log(++counter);
}
},
complete() {
isComplete = true;
},
});