This file contains hidden or 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
$ node r.js -o name=main out=main-built.js baseUrl=. |
This file contains hidden or 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
JAVASCRIPT_DIR := ./static/js | |
js: | |
bower install | |
jsx $(JAVASCRIPT_DIR)/src $(JAVASCRIPT_DIR)/build | |
node $(JAVASCRIPT_DIR)/lib/r.js/dist/r.js -o $(JAVASCRIPT_DIR)/build/buildconfig.js |
This file contains hidden or 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
/** @jsx React.DOM */ | |
var MyJSXComponent = React.createClass({ | |
render: function() { | |
return <div>Hello, {this.props.name}</div>; | |
}, | |
}); | |
// This is the compiled output of MyJSXComponent. | |
var MyJSComponent = React.createClass({ | |
render: function() { |
This file contains hidden or 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
var Button = React.createClass({ | |
getInitialState: function() { | |
return {count: 0}; | |
}, | |
render: function() { | |
return ( | |
<button type="button" onClick={this.handleClick}> | |
{'Clicked ' + this.state.count + ' time(s)'} | |
</button> |
This file contains hidden or 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
var Foo = React.createClass({ | |
render : function() { | |
return <div>foo</div>; | |
}, | |
}); | |
var Bar = React.createClass({ | |
render : function() { | |
return <div>bar</div>; | |
}, |
This file contains hidden or 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
if __name__ == '__main__': | |
app = create_app() | |
server = SocketIOServer( | |
('0.0.0.0', 5000), | |
SharedDataMiddleware(app, {}), | |
policy_server=False) | |
server.serve_forever() |
This file contains hidden or 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
@blueprint.route('/socket.io/<path:path>') | |
def run_socketio(path): | |
socketio_manage( | |
request.environ, {'/notifications': NotificationsNamespace}) | |
return '' |
This file contains hidden or 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
class NotificationsNamespace(BaseNamespace, BroadcastMixin): | |
"""Socket.IO namespace for broadcasting notifications.""" | |
def __init__(self, *args, **kwargs): | |
global _redis | |
_redis = redis.StrictRedis('localhost', 6379, db=0) | |
self.pubsub = _redis.pubsub() | |
self.pubsub.subscribe('notifications') | |
super(NotificationsNamespace, self).__init__(*args, **kwargs) |
This file contains hidden or 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
def notify(event, payload): | |
"""Publish an event notification to all subscribers. | |
Args: | |
event: the name of the event. | |
payload: dict consisting of the event payload. | |
""" | |
global _redis | |
if _redis: |
This file contains hidden or 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
var dispatcher = _.clone(Backbone.Events); | |
var fooView = new FooView({ | |
dispatcher: dispatcher | |
}); | |
var barView = new BarView({ | |
dispatcher: dispatcher | |
}); | |
var bazView = new BazView({ | |
dispatcher: dispatcher | |
}); |