Sha256: e53f1aacab509d98dda8f1599f2fdeb2954add60943cdb70fda3839bb08e98b5
Contents?: true
Size: 1.57 KB
Versions: 8
Compression:
Stored size: 1.57 KB
Contents
(function() { Rev.registerComponent('ModelPrepper', { mixins: [Rev.Mixins.BackboneStore], getInitialState: function() { var state; return state = { model: null, error: null }; }, componentWillMount: function() { return this.fetch(); }, get: function() { return this.store.get(this.props.collection, this.props.model); }, fetch: function() { return this.store.fetch(this.props.collection, this.props.model, this.onFetchComplete); }, onFetchComplete: function() { var model; if (model = this.get()) { return this.setState({ model: model }); } else { return this.setState({ error: true }); } }, render: function() { if (this.state.model != null) { return this.success(); } else if (this.state.error != null) { return this.error(); } else { return this.wait(); } }, success: function() { if (this.props.onSuccess != null) { return this.props.onSuccess(this.state.model, this); } else { return this.props.children; } }, error: function() { if (this.props.onError != null) { return this.props.onError(this.retry); } else { return null; } }, wait: function() { if (this.props.onWait != null) { return this.props.onWait(); } else { return null; } }, retry: function() { return this.setState({ error: null }); } }); }).call(this);
Version data entries
8 entries across 8 versions & 1 rubygems