Created
September 10, 2014 22:02
-
-
Save webOS101/c4b0f1f63d7ef133d0e4 to your computer and use it in GitHub Desktop.
Instance Counter
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
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'}); | |
}); |
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
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