mirror of
https://github.com/jupyter/notebook.git
synced 2025-02-05 12:19:58 +08:00
Merge pull request #7093 from jasongrout/model-views
Make the model.views dict a dict of promises for views
This commit is contained in:
commit
e519371402
@ -112,6 +112,7 @@ define([
|
||||
return Promise.resolve(view.render()).then(function() {return view;});
|
||||
}).catch(utils.reject("Couldn't create a view for model id '" + String(model.id) + "'", true));
|
||||
});
|
||||
model.views[utils.uuid()] = model.state_change;
|
||||
return model.state_change;
|
||||
};
|
||||
|
||||
|
@ -65,11 +65,12 @@ define(["widgets/js/manager",
|
||||
delete this.comm.model; // Delete ref so GC will collect widget model.
|
||||
delete this.comm;
|
||||
delete this.model_id; // Delete id from model so widget manager cleans up.
|
||||
for (var id in this.views) {
|
||||
if (this.views.hasOwnProperty(id)) {
|
||||
this.views[id].remove();
|
||||
}
|
||||
}
|
||||
_.each(this.views, function(v, id, views) {
|
||||
v.then(function(view) {
|
||||
view.remove();
|
||||
delete views[id];
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
_handle_comm_msg: function (msg) {
|
||||
@ -318,8 +319,6 @@ define(["widgets/js/manager",
|
||||
*/
|
||||
this.model.on('change',this.update,this);
|
||||
this.options = parameters.options;
|
||||
this.id = this.id || utils.uuid();
|
||||
this.model.views[this.id] = this;
|
||||
this.on('displayed', function() {
|
||||
this.is_displayed = true;
|
||||
}, this);
|
||||
|
Loading…
Reference in New Issue
Block a user