Skip to content

Instantly share code, notes, and snippets.

@jiggliemon
Last active December 14, 2015 01:49
Show Gist options
  • Select an option

  • Save jiggliemon/5009595 to your computer and use it in GitHub Desktop.

Select an option

Save jiggliemon/5009595 to your computer and use it in GitHub Desktop.
var Obj = require('parsed/object')
var LocalStorage = require('parsed/object/localstorage')
var Validation = require('parsed/object/validation')
var Task = Obj.create('Task', {
implement: [LocalStorage, Validation]
}, {
init: function () {
}
})
@GCheung55
Copy link

Then in init i would do:

init: function(){
    this.setupLocalStorage(options);
    this.setupValidation(options);
},

set: function(key, value){
    // assuming access to parent class object
    // this would validate because we've setup validation.
    // and if we're using emitting events in the "parent" set method,
    // then setupLocationStorage would be written to attach itself to the events
    // emitted by the set method.
    if (this.validate(key, value)) this.parent('set', key, value);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment