Created
February 5, 2016 17:18
-
-
Save vitkarpov/3313ed676e1cc48559e5 to your computer and use it in GitHub Desktop.
Jblocks: an example of declaration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jBlocks.define('counter', { | |
events: { | |
'click .js-inc': 'inc', | |
'click .js-dec': 'dec' | |
}, | |
methods: { | |
oninit: function() { | |
this._currentValue = Number(this.params.initialValue); | |
}, | |
ondestroy: function() { | |
this._currentValue = null; | |
}, | |
/** | |
* Increases the counter, emits changed event | |
*/ | |
inc: function() { | |
this._currentValue++; | |
this.emit('changed', this._currentValue); | |
}, | |
/** | |
* Decreases the counter, emits changed event | |
*/ | |
dec: function() { | |
this._currentValue--; | |
this.emit('changed', this._currentValue); | |
}, | |
/** | |
* Returns the current value | |
* @return {Number} | |
*/ | |
getCurrentValue: function() { | |
return this._currentValue; | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment