{"action":"opened","issue":{"url":"https://api.github.com/repos/baconjs/bacon.js/issues/508","labels_url":"https://api.github.com/repos/baconjs/bacon.js/issues/508/labels{/name}","comments_url":"https://api.github.com/repos/baconjs/bacon.js/issues/508/comments","events_url":"https://api.github.com/repos/baconjs/bacon.js/issues/508/events","html_url":"https://github.com/baconjs/bacon.js/issues/508","id":53254445,"number":508,"title":"flatMapError","user":{"login":"phadej","id":51087,"avatar_url":"https://avatars.githubusercontent.com/u/51087?v=3","gravatar_id":"","url":"https://api.github.com/users/phadej","html_url":"https://github.com/phadej","followers_url":"https://api.github.com/users/phadej/followers","following_url":"https://api.github.com/users/phadej/following{/other_user}","gists_url":"https://api.github.com/users/phadej/gists{/gist_id}","starred_url":"https://api.github.com/users/phadej/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phadej/subscriptions","organizations_url":"https://api.github.com/users/phadej/orgs","repos_url":"https://api.github.com/users/phadej/repos","events_url":"https://api.github.com/users/phadej/events{/privacy}","received_events_url":"https://api.github.com/users/phadej/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/baconjs/bacon.js/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-01-02T14:13:21Z","updated_at":"2015-01-02T14:13:21Z","closed_at":null,"body":"We have\r\n- `observable.map(@ : Observable[A], f : A -> B) : Observable[B]`\r\n- `observable.flatMap(@ : Observable[A], f : A -> Observable[B] | Event[B] | B) : EventStream[B]`\r\n- `observable.mapError(@ : Observable[A], f : E -> A) : Observable[A]`\r\n\r\nShould we have\r\n```js\r\nobservable.flatMapError(@ : Observable[A], f : E -> Observable[A] | Event[A] | A) : EventStream[A]\r\n```\r\nfor completeness?\r\n\r\n*Extra:* how about\r\n- `observable.eventMap(@ : Observable[A], f : E -> Array[Event[B] | B] | Event[B] | B) : Observable[B]`\r\n- `observable.eventMapError(@ : Observable[A], f : E -> Array[Event[A] | A] | Event[A] | A) : EventStream[A]`\r\nwith or without `Array magic`.\r\n\r\n`eventMap` would be generalisation of `filter` and  `eventMapError` is usable when you want to recover only from some errors.\r\n\r\n```js\r\nstream\r\n  .map(function (x) {\r\n    return [x, x];\r\n  })\r\n  .flatMap(Bacon.fromArray)\r\n// or\r\nstream.eventMap(function (x) {\r\n  return [x, x];\r\n});\r\n```"}}