UNPKG

543 BTypeScriptView Raw
1import { EventStream } from "./observable";
2/**
3 `Bacon.try` is a helper for creating an EventStream of a single value, or a single Error event in case the given
4 function throws an exception.
5
6For example, you can use `Bacon.try` to handle JSON parse errors:
7
8```js
9var jsonStream = Bacon
10 .once('{"this is invalid json"')
11 .flatMap(Bacon.try(JSON.parse))
12
13jsonStream.onError(function(err) {
14 console.error("Failed to parse JSON", err)
15})
16
17 */
18export default function tryF<In, Out>(f: (value: In) => Out): (value: In) => EventStream<Out>;