Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[update] order of destroy and init events #22

Merged
merged 2 commits into from
Feb 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions dist/JetApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,6 @@ var JetApp = (function (_super) {
_this._view = view;
// render url state for the root
return view.render(_this._container, parsed, _this._parent).then(function (root) {
// destroy and detack old view
if (oldview && oldview !== _this._view) {
oldview.destructor();
}
if (_this._view.getRoot().getParentView()) {
_this._container = root;
}
Expand Down
14 changes: 10 additions & 4 deletions dist/JetView.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,17 @@ var JetView = (function (_super) {
result.ui.id = prev.config.id;
}
}
var oldScope = this._container.$scope;
this._root = this.app.webix.ui(result.ui, this._container);
// check, if some other view need to be destroyed
if (oldScope && oldScope !== this && oldScope.getRoot && oldScope.getRoot().$destructed) {
if (oldScope.app !== this.app && oldScope.app.getRoot().$destructed) {
oldScope.app.destructor();
}
else {
oldScope.destructor();
}
}
if (this._root.getParentView()) {
this._container = this._root;
}
Expand Down Expand Up @@ -255,10 +265,6 @@ var JetView = (function (_super) {
JetView.prototype._renderSubView = function (sub, view, suburl) {
var cell = this.app.webix.$$(sub.id);
return view.render(cell, suburl, this).then(function (ui) {
// destroy old view
if (sub.view && sub.view !== view) {
sub.view.destructor();
}
// save info about a new view
sub.view = view;
sub.id = ui.config.id;
Expand Down
5 changes: 0 additions & 5 deletions sources/JetApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,6 @@ export class JetApp extends JetBase implements IJetApp {

// render url state for the root
return view.render(this._container, parsed, this._parent).then(root => {

// destroy and detack old view
if (oldview && oldview !== this._view) {
oldview.destructor();
}
if (this._view.getRoot().getParentView()){
this._container = root;
}
Expand Down
15 changes: 10 additions & 5 deletions sources/JetView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,17 @@ export class JetView extends JetBase{
}
}

const oldScope = (this._container as any).$scope;
this._root = this.app.webix.ui(result.ui, this._container);
// check, if some other view need to be destroyed
if (oldScope && oldScope !== this && oldScope.getRoot && oldScope.getRoot().$destructed){
if (oldScope.app !== this.app && oldScope.app.getRoot().$destructed){
oldScope.app.destructor();
} else {
oldScope.destructor();
}
}

if (this._root.getParentView()){
this._container = this._root;
}
Expand Down Expand Up @@ -286,11 +296,6 @@ export class JetView extends JetBase{
suburl:IJetURL):Promise<webix.ui.baseview>{
const cell = this.app.webix.$$(sub.id);
return view.render(cell, suburl, this).then(ui => {
// destroy old view
if (sub.view && sub.view !== view){
sub.view.destructor();
}

// save info about a new view
sub.view = view;
sub.id = ui.config.id as string;
Expand Down