Skip to content

Instantly share code, notes, and snippets.

@clinuz
Last active December 25, 2015 19:19
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 clinuz/ed0ca11492b6f65fca6e to your computer and use it in GitHub Desktop.
Save clinuz/ed0ca11492b6f65fca6e to your computer and use it in GitHub Desktop.
Example of how to avoid sharing array/object references between kinds in Enyo (or JavaScript).
enyo.kind({
name: "sample.Control",
// some property that is an array that gets modified per-instance
// means we can't supply one to be shared for all instances
// so we assign it to null
myArrayProp: null,
constructor: function () {
// here we can use 'this' for our instance and assign a new array
// that will not be shared with other instances of our kind
this.myArrayProp = [];
return this.inherited(arguments);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment