Created
October 5, 2014 03:51
-
-
Save rattrayalex/5617976719f7d8ead154 to your computer and use it in GitHub Desktop.
FluxBone Mixin for React
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = | |
ModelMixin: (model_name, event_name="all") -> | |
eventCallbackName = "_eventCallbacks_#{ model_name }_#{ event_name }" | |
mixin = | |
componentDidMount: -> | |
@props[model_name].on event_name, | |
@[eventCallbackName] | |
@ | |
componentWillUnmount: -> | |
@props[model_name].off event_name, | |
@[eventCallbackName] | |
@ | |
mixin[eventCallbackName] = () -> | |
setTimeout => | |
@forceUpdate() | |
, 0 | |
return mixin | |
CollectionMixin: (collection_name, event_name="all") -> | |
eventCallbackName = "_eventCallbacks_#{ collection_name }_#{ event_name }" | |
mixin = | |
componentDidMount: -> | |
@props[collection_name].on event_name, | |
@[eventCallbackName] | |
@ | |
componentWillUnmount: -> | |
@props[collection_name].off event_name, | |
@[eventCallbackName] | |
@ | |
mixin[eventCallbackName] = () -> | |
setTimeout => | |
@forceUpdate() | |
, 0 | |
return mixin | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Link to what I'm afraid of dealing with when trying to sync immutables with the server: https://github.com/rattrayalex/FluxBone_Example/tree/master/immutable_comparison