A Promise
may be thought of as a linear Observable; an Observable may be
thought of as a non-linear Promise
.
const promise = keep(new Promise((resolve) => {
setTimeout(() => {
resolve("hello from 2 seconds ago");
}, 2000);
}));
const activity = promise.subscribe(
(msg: string) => void console.log(msg)
);
# prints
hello from 2 seconds ago
Generated using TypeDoc
Converts a
Promise
into an Observable which fires once. Any exceptions thrown while awaiting the promise will be re-thrown. If an exception is thrown the observer will definitely not be called.