Skip to content

Instantly share code, notes, and snippets.

@carlmw
Last active August 29, 2015 13:57
Show Gist options
  • Save carlmw/9413369 to your computer and use it in GitHub Desktop.
Save carlmw/9413369 to your computer and use it in GitHub Desktop.
broker wrapper
// Renders a React component within rootEl
var handlers = [];
Fave.render = function (React, NS, rootEl, module) {
var component = NS[module](_.extend({}, Fave.broker, {
on: function (name, fn) {
handlers.push({ name: name, fn: fn });
return Fave.broker.on(name, fn);
}
})
return Fave.broker
);
if (handlers.length) {
handlers.forEach(function (handler) {
Fave.broker.off(handler.name, handler.fn);
});
handlers.length = 0;
}
// TODO unmountComponentAtNode
if (component) React.renderComponent(component, rootEl);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment