Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember cleanup on leaving route

I want to make some cleanup when i leave route, like stopping timers. For that i need an event that triggers when leaving the route, and i need access to instance of controller inside of that event.

There is an exit event, but it doesn't get any arguments, and this.get('controller') inside it doesn't work too - returns undefined.

Is there a proper way for obtaining controller instance in the exit event, or, maybe, another event that i don't know of?

I setup this fiddle with an example of what i want..

like image 712
Shimon Rachlenko Avatar asked Nov 12 '22 11:11

Shimon Rachlenko


1 Answers

You can achieve this by calling this.controllerFor('home'). You can try it in this JSFiddle.

This is a little bit annoying, so a pull request has been merged recently that allows you to directly use this.controller, as you can see in this JSFiddle.

like image 139
louiscoquio Avatar answered Nov 15 '22 13:11

louiscoquio