StatefulModel
Closed this issue · 5 comments
sebpiq commented
With intermediary states like "destroying", "saving", and so on ...
donaldr commented
I second having a StatefulModel class.
sebpiq commented
Never really had the need for that myself ... so any idea what functionalities it should offer that vanilla StateMachine doesn't already have?
donaldr commented
It would mostly be syntactic sugar so that I don't have to manually mixin the state machine on a Backbone model object. There isn't much utility other than that.
I just cribbed the shell of Backbone.StatefulView and do this:
Backbone.StatefulModel = (function(Backbone, _) {
var StatefulModel = function(options) {
this.startStateMachine(options);
Backbone.Model.prototype.constructor.apply(this, arguments);
}
_.extend(StatefulModel.prototype, Backbone.Model.prototype, Backbone.StateMachine);
StatefulModel.extend = Backbone.Model.extend;
return StatefulModel;
}(Backbone, _));
sebpiq commented
Ok ... I'll add that now. If by using it you find that there should be some extra functionality, please suggest it here!