@thatsmrtalbot/observer
v1.0.0
Published
[![Build Status](https://travis-ci.org/ThatsMrTalbot/observer.svg?branch=master)](https://travis-ci.org/ThatsMrTalbot/observer)
Downloads
2
Readme
Typescript Observer
Simple observer to compliment promise
Usage
Like promise you construct an observer using a callback:
let observer = new Observer<string>((next, error, done) => {
next("a");
next("b");
next("c");
done();
})
From here you can itterate over the values, a promise is retuened to detect errors/completion:
try {
await observer.itterate((next : string) => {
console.log(`Next: ${next}`);
})
} catch(e) {
console.error(`Error: ${e}`);
}
console.log("Done");