UNPKG

1.14 kBTypeScriptView Raw
1import { EventTransformer } from "./frombinder";
2import { EventStream } from "./observable";
3/**
4 * Creates an EventStream from a Promise object such as JQuery Ajax.
5 This stream will contain a single value or an error, followed immediately by stream end.
6 You can use the optional abort flag (i.e. ´fromPromise(p, true)´ to have the `abort` method of the given promise be called when all subscribers have been removed from the created stream.
7 You can also pass an optional function that transforms the promise value into Events. The default is to transform the value into `[new Bacon.Next(value), new Bacon.End()]`.
8 Check out this [example](https://github.com/raimohanska/baconjs-examples/blob/master/resources/public/index.html).
9
10 *
11 * @param {Promise<V>} source promise object
12 * @param abort should we call the `abort` method of the Promise on unsubscribe. This is a nonstandard feature you should probably ignore.
13 * @param {EventTransformer<V>} eventTransformer
14 * @returns {EventStream<V>}
15 */
16export default function fromPromise<V>(promise: Promise<V>, abort?: boolean, eventTransformer?: EventTransformer<V>): EventStream<V>;