Skip to content

Instantly share code, notes, and snippets.

@axefrog
Last active January 17, 2017 04:17
Show Gist options
  • Save axefrog/2442f367c623f8e5d5b525232cc733cd to your computer and use it in GitHub Desktop.
Save axefrog/2442f367c623f8e5d5b525232cc733cd to your computer and use it in GitHub Desktop.
A cleaner abstraction for creating and resolving stream proxies
import {using} from 'proxy-abstraction';
function render() {
// The `using` function takes a callback function. It looks at the functions `.length` property
// and generates a proxy for each. You then return a tuple containing the value you want to
// persist, and fulfillment streams for each of the referenced proxies. The using function will
// automatically complete the proxies internally and return the first tuple argument.
return using((click$, hover$) => {
const view = div(......);
return [
view,
view.events.click,
view.events.mouseOver
];
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment