Last active
January 10, 2017 21:11
-
-
Save ofridagan/de53bafce2f20193f294b12bab983b32 to your computer and use it in GitHub Desktop.
New Twiddle
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
var WatchedObject = Ember.Object.extend({ | |
"*": null, | |
setUnknownProperty: function(k,v){ | |
var self = this; | |
self.addObserver(k, function(){ | |
Ember.run.once(self, 'somethingChanged'); | |
}); | |
Ember.defineProperty(this, k, null, v); | |
this.notifyPropertyChange(k); | |
}, | |
init: function(){ | |
this._super(); | |
var self = this; | |
Ember.keys(this).forEach(function(key){ | |
if(Ember.typeOf(self.get(key)) !== 'function'){ | |
self.addObserver(key, function(){ | |
Ember.run.once(self, 'somethingChanged'); | |
}); | |
} | |
}); | |
}, | |
somethingChanged: function() { | |
this.notifyPropertyChange('*'); | |
} | |
}); | |
var MyTrips = WatchedObject.extend({ | |
numberOfTrips: (function(){ | |
return Ember.keys(this).length | |
}).property("*") | |
}); | |
export default Ember.Controller.extend({ | |
trips: null, | |
init: function(){ | |
this._super(); | |
this.set('trips', MyTrips.create()); | |
var i=0; | |
var self = this; | |
setInterval(function(){ | |
self.get('trips').set('tripNumber'+i, 'some trip'); | |
i++; | |
}, 400); | |
} | |
}); |
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
{ | |
"version": "0.10.7", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "1.13.13", | |
"ember-data": "2.10.0", | |
"ember-template-compiler": "1.13.13", | |
"ember-testing": "1.13.13" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment