isExiting - true on model change

I’m using Ember 3.4. I have a variable which becomes true on a button click. I have also included loading.hbs file in my app.

In dummy.hbs file:
<button {{action "reload"}}>Refresh</button>
 <button {{action "setToTrue"}}>Change To True</button>

In controller file dummy.js:
 setToTrue() {
      this.set("dummyVar", true);
    reload() {

In route File dummy.js:
resetController(controller, isExiting) {
    if (isExiting) {

 //isExiting would be false if only the route's model was changing
      controller.set("dummyVar", false);
  actions: {
    reloadDetails() {

When I click the button setToTrue, the value changes to True and it is displayed. But when I click refresh button, The variable “dummyVar” is set to false. The variable “dummyVar” should be changed to false only when “isExiting” is true. My question is When this.refresh is called, will the “isExiting” changed to “true” ? When I tried refreshing without creating loading.hbs, isExiting was “false”

Is this the actual behavior? Will Loading.hbs affect the isExiting value??

I have attached a twiddle link demonstrating the above problem

1 Like

I don’t actually know the details of resetController's behavior off the top of my head, but the reason for that is that the remaining uses for it in modern Ember are extremely narrow. You almost certainly don’t need it.

It sounds like you have some state on a controller that you want to clean up upon leaving the route. But that means you should move that state out of the controller and into a component, and then it will automatically get the right lifetime and you won’t need to do any cleanup.

1 Like