Skip to content

Instantly share code, notes, and snippets.

@webOS101
Created September 10, 2014 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webOS101/c4b0f1f63d7ef133d0e4 to your computer and use it in GitHub Desktop.
Save webOS101/c4b0f1f63d7ef133d0e4 to your computer and use it in GitHub Desktop.
Instance Counter
enyo.ready(function() {
enyo.kind({
name: 'InstanceCounter',
constructor: function() {
InstanceCounter.count += 1;
this.inherited(arguments);
},
statics: {
count: 0,
currentCount: function() {
return(this.count);
}
}
});
enyo.kind({
name: 'View',
components: [
{kind: 'InstanceCounter'},
{kind: 'InstanceCounter'},
{name: 'total'}
],
rendered: function() {
this.inherited(arguments);
this.set('$.total.content', 'Total InstanceCounters: ' + InstanceCounter.currentCount())
}
});
new enyo.Application({name: 'app', view: 'View'});
});
name: Instance Counter
description: An example of using statics and constructors
authors:
- Roy Sutton
normalize_css: no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment