{"action":"created","issue":{"url":"https://api.github.com/repos/rpominov/kefir/issues/111","labels_url":"https://api.github.com/repos/rpominov/kefir/issues/111/labels{/name}","comments_url":"https://api.github.com/repos/rpominov/kefir/issues/111/comments","events_url":"https://api.github.com/repos/rpominov/kefir/issues/111/events","html_url":"https://github.com/rpominov/kefir/issues/111","id":87313876,"number":111,"title":"Explode one event into zero or more","user":{"login":"Twisol","id":61392,"avatar_url":"https://avatars.githubusercontent.com/u/61392?v=3","gravatar_id":"","url":"https://api.github.com/users/Twisol","html_url":"https://github.com/Twisol","followers_url":"https://api.github.com/users/Twisol/followers","following_url":"https://api.github.com/users/Twisol/following{/other_user}","gists_url":"https://api.github.com/users/Twisol/gists{/gist_id}","starred_url":"https://api.github.com/users/Twisol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Twisol/subscriptions","organizations_url":"https://api.github.com/users/Twisol/orgs","repos_url":"https://api.github.com/users/Twisol/repos","events_url":"https://api.github.com/users/Twisol/events{/privacy}","received_events_url":"https://api.github.com/users/Twisol/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-06-11T11:40:38Z","updated_at":"2015-06-11T12:33:33Z","closed_at":"2015-06-11T12:32:48Z","body":"I've found the following pattern fairly useful in one of my current projects. It allows you to transform one event into multiple (or none). Does anything like this exist currently in Kefir? I see that a map+flatten combo would work in the example below, but in my use-case it isn't immediately natural to collect results as an array.\r\n\r\n```javascript\r\nKefir.Stream.prototype.explode = function(fn) {\r\n  return this.withHandler(function(emitter, ev) {\r\n    if (ev.type === \"end\") {\r\n      emitter.end();\r\n    } else if (ev.type === \"value\") {\r\n      fn(emitter, ev.value);\r\n    }\r\n  });\r\n};\r\n```\r\n\r\nUsage:\r\n```javascript\r\nvar things$ = Kefir.sequentially(100, [\"abc\\ndef\", \"ghi\\njkl\\nmno\"]);\r\nvar lines$ = things$.explode(function(emitter, value) {\r\n  value.split(\"\\n\").forEach(function(line) {\r\n    emitter.emit(line);\r\n  });\r\n});\r\n```"},"comment":{"url":"https://api.github.com/repos/rpominov/kefir/issues/comments/111116608","html_url":"https://github.com/rpominov/kefir/issues/111#issuecomment-111116608","issue_url":"https://api.github.com/repos/rpominov/kefir/issues/111","id":111116608,"user":{"login":"Twisol","id":61392,"avatar_url":"https://avatars.githubusercontent.com/u/61392?v=3","gravatar_id":"","url":"https://api.github.com/users/Twisol","html_url":"https://github.com/Twisol","followers_url":"https://api.github.com/users/Twisol/followers","following_url":"https://api.github.com/users/Twisol/following{/other_user}","gists_url":"https://api.github.com/users/Twisol/gists{/gist_id}","starred_url":"https://api.github.com/users/Twisol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Twisol/subscriptions","organizations_url":"https://api.github.com/users/Twisol/orgs","repos_url":"https://api.github.com/users/Twisol/repos","events_url":"https://api.github.com/users/Twisol/events{/privacy}","received_events_url":"https://api.github.com/users/Twisol/received_events","type":"User","site_admin":false},"created_at":"2015-06-11T12:33:33Z","updated_at":"2015-06-11T12:33:33Z","body":"Missed that somehow. Thanks!"}}