Closed dgpt closed 10 years ago
There's also the onSwitch
function (Which I should probably rename). I think it'll be more flexible as a prototype. especially because of all the reuse the state has to do. nevermind.
This also seems hard to read if we were to have a new state far away from the State function declaration, since there's no names on the functions you'd just have to remember the order. But we could just pass it as an object. { update: function(){}, init: function() {} }
Hm, good point. It's definitely more flexible as a prototype. What do you mean by 'all the reuse the state has to do'?
We could do an object or we could name the functions new State(function init() {}, function update() {});
Oh yeah I suppose that would work to. But yeah I think leaving it would be best.
I don't know if States even need prototypes, actually. Here's how I wanted to do them.
Since we'd only be rewriting the init and update functions every time, it makes sense to just use callbacks instead.