Merge lp:~makyo/juju-gui/endpoints-once into lp:juju-gui/experimental
Proposed by
Madison Scott-Clary
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 264 | ||||
Proposed branch: | lp:~makyo/juju-gui/endpoints-once | ||||
Merge into: | lp:juju-gui/experimental | ||||
Diff against target: |
114 lines (+59/-7) 2 files modified
app/app.js (+29/-5) test/test_app.js (+30/-2) |
||||
To merge this branch: | bzr merge lp:~makyo/juju-gui/endpoints-once | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju GUI Hackers | Pending | ||
Review via email: mp+137273@code.launchpad.net |
Description of the change
Clean up get_endpoints
get_endpoints was being called on every instance of service_add and not being garbage collected. Moved it to on_database_changed and added gc around services being removed.
To post a comment you must log in.
Reviewers: mp+137273_ code.launchpad. net,
Message:
Please take a look.
Description:
Clean up get_endpoints
get_endpoints was being called on every instance of service_add and not
being garbage collected. Moved it to on_database_changed and added gc
around services being removed.
https:/ /code.launchpad .net/~makyo/ juju-gui/ endpoints- once/+merge/ 137273
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/6858099/
Affected files:
A [revision details]
M app/app.js
Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: <email address hidden>
+New revision: <email address hidden>
Index: app/app.js
this.db. on('update' , this.on_ database_ changed, this);
=== modified file 'app/app.js'
--- app/app.js 2012-11-20 16:55:43 +0000
+++ app/app.js 2012-11-30 17:33:27 +0000
@@ -256,8 +256,6 @@
// TODO - Bound views will automatically update this on individual
models
- this.db. services. on('add' , this.updateEndp oints, this);
this.on( 'navigate' , function(e) {
console. log('app navigate', e); database_ changed: function(evt) { isValue( this.serviceEnd points) ) { points = {}; services. some(function( service) { dpoints[ service. get('id' )] === undefined) { oints() ; each(this. serviceEndpoint s, function(key, value, obj) { services. getById( key) === null) { self.serviceEnd points[ key]);
this.dispatch( ); points: function(callback) {
-
});
@@ -310,6 +308,35 @@
*/
on_
Y.log(evt, 'debug', 'App: Database changed');
+
+ var updateNeeded = false,
+ self = this;
+ if (!Y.Lang.
+ this.serviceEnd
+ }
+
+ // Compare endpoints map against db to see if it needs to be changed.
+ this.db.
+ if (self.serviceEn
+ updateNeeded = true;
+ }
+ return updateNeeded;
+ });
+
+ // If there are new services in the DB, pull an updated endpoints
map.
+ if (updateNeeded) {
+ this.updateEndp
+ } else {
+ // Check to see if any services have been removed (if there are,
and
+ // new ones also, updateEndpoints will replace the whole map, so
only
+ // do this if needed).
+ Y.Object.
+ if (self.db.
+ delete(
+ }
+ });
+ }
+
// Redispatch to current view to update.
},
@@ -322,9 +349,6 @@
updateEnd
var self = this;
- if (!Y.Lang. isValue( this.serviceEnd points) ) { points = {}; env.get( 'connected' )) {
- this.serviceEnd
- }
// Defensive code to aid tests. Other systems
// don't have to mock enough to get_endpoints below.
if (!this.