Skip to content

Instantly share code, notes, and snippets.

@StoneCypher
Created August 7, 2015 16:58
Show Gist options
  • Select an option

  • Save StoneCypher/93ef8f36eb03902df542 to your computer and use it in GitHub Desktop.

Select an option

Save StoneCypher/93ef8f36eb03902df542 to your computer and use it in GitHub Desktop.
var React = ...
var Editor = React.createClass({ ... });
var App = {
savedValue : 'Hello, World!',
currentValue : 'Hello, World!',
hot : false,
change : function(X) { this.currentValue = X; hot = true; this.rerender(); },
save : function(X) { this.savedValue = this.currentValue; hot = false; this.rerender(); },
abort : function(X) { this.currentValue = this.savedValue; hot = false; this.rerender(); },
rerender : function(Hot) { React.render(document.body, <Editor hot={this.hot} val={this.currentValue} hooks={...} />); },
};
// where hooks is just an object that passes down change, save, and abort
// put these in contexts and you don't even have to pass them down
// and now you use flocks.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment