-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Make a public detachView #3155
Make a public detachView #3155
Conversation
This function removes the need for a `preventDestroy` option. Essentially if you want to `preventDestroy` just detach the view first. When you want to preventDestroy you already have to have a copy of the view.. and depending on what is doing the view emptying `preventDestroy` can become a round about API. What you really want is ```js const myView = myRegion.currentView; myRegion.detachView(); myOtherRegion.show(myView); ```
how about var view = parentView.detachChildView('region');
myOtherRegion.show(myView); which proxies detachView. That way people don't directly interact with the region. |
I think a |
Hooo I like those ideas. @rafde your idea of an API from layout point of view is cool! |
Yeah, I'm 👍 for this. Someone in gitter wanted something like this. @paulfalgout mind if I help with the |
detachChildView(region){
return this.getRegion(region).detachView();
} detachView() {
const view = this.currentView;
if(!view){
return;
}
delete this.currentView;
this._detachView(view);
delete view._parent;
return view; // I think this should return the view getting detached
}, |
@rafde you can take it over if you want. good call about the return if |
Ah right, @paulfalgout. I get that you don't want to write up the test, 😄 . |
@rafde we can move it, or you can PR on my branch, or just close this and reopen another.. I'm up for whatever.. I mean I'll also do it eventually, but if you wanted to step in 👯 |
I'll PR against yours for now. |
detachView * falsy check Regions detachChildView
detachChildView
detachView
@paulfalgout paulfalgout#4 forgot the docs, though. |
[documentation] View#detachChildView
Region detachview detach child view
Nice i like this. Should we add a deprectation notice to |
@@ -180,6 +180,10 @@ export default { | |||
return region.show(view, ...args); | |||
}, | |||
|
|||
detachChildView(name) { | |||
return this.getRegion(name).detachView(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
forgot to do a region exist check
const region = this.getRegion(name);
if (!region) {
return;
}
return region.detachView();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW that check isn't being done in other places
welp, I am done here. 👍 |
Nice! Just concerned about that check on |
@JSteunou I am not sure what you are looking for. Snippet of what you mean by "checking + logging in debug mode", please. |
I'm in general more interested in consistency over completeness. Even if it is decided that we should be throwing a warning in debug or an error or whatever.. we should handle that in a later issue and across the lib. |
I am for that sentiment. |
@paulfalgout completely agreed, just throwing the ball. Wouldnt make this PR fuzzy with a lot of changes not related. Nice work btw guys 👍 |
I'll add a 👍 too |
This function removes the need for a
preventDestroy
option. #2640Essentially if you want to
preventDestroy
just detach the view first. When you want to preventDestroy you already have to have a copy of the view.. and depending on what is doing the view emptyingpreventDestroy
can become a round about API.What you really want is
Upon approval: