# Detached() not firing in composed view

**URL:** <https://discourse.aurelia.io/t/detached-not-firing-in-composed-view/1559>\
**Category:** Help Requests\
**Created:** [August 22, 2018, 3:51pm UTC](https://discourse.aurelia.io/t/detached-not-firing-in-composed-view/1559 "2018-08-22T15:51:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdickinson](https://avatars.discourse-cdn.com/v4/letter/j/5fc32e/32.png) [@jdickinson](https://discourse.aurelia.io/u/jdickinson)\
**Post date:** [August 22, 2018, 3:51pm UTC](https://discourse.aurelia.io/t/detached-not-firing-in-composed-view/1559/1 "2018-08-22T15:51:32Z")

</div>

My problem is this:

I have a view (with its own viewmodel) that has 2 composed view/viewmodel pairs inside it. One of these ‘embedded’ viewmodels has an Aurelia eventAggregator subscriber defined in activate(). I want to dispose() of this subscriber in the ‘embedded’ VM’s detached() method. However, the ‘embedded’ detached() method never seems to run, when navigating away from the (outer or ‘main’) view, although the outer or ‘main’ view’s detached() method DOES fire

One result of this is that the subscribed event in the ‘embedded’ viewmodel continues to receive events, even though the page within which it is contained has been navigated away from. Obviously totally undesirable!

Any ideas please?

Cheers

---

<div class="post-metadata">

**Author:** ![bigopon](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/bigopon/32/18_2.png) [@bigopon](https://discourse.aurelia.io/u/bigopon)\
**Post date:** [August 22, 2018, 9:17pm UTC](https://discourse.aurelia.io/t/detached-not-firing-in-composed-view/1559/2 "2018-08-22T21:17:24Z")

</div>

From the source code, [https://github.com/aurelia/templating-resources/blob/master/src/compose.js](https://github.com/aurelia/templating-resources/blob/master/src/compose.js), it does not seem `<compose/>` handles `attached/detached` life cycle. You can use `bind, unbind` to work around it. Unfortunately we cannot add it in at this stage as it could be a big breaking change. Note that `detached` will still fire in the end. Im interested in your scenario, can you share a simple gist to demonstrate the issue ?

---

<div class="post-metadata">

**Author:** ![vegarringdal](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/vegarringdal/32/248_2.png) [@vegarringdal](https://discourse.aurelia.io/u/vegarringdal)\
**Post date:** [August 31, 2018, 4:20pm UTC](https://discourse.aurelia.io/t/detached-not-firing-in-composed-view/1559/3 "2018-08-31T16:20:21Z")

</div>

dunno if I remember wrong/mixing this with something else. Have you tried router typical events.

- activate
- deactivate

---

<div class="post-metadata">

**Author:** ![avrahamcool](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/avrahamcool/32/368_2.png) [@avrahamcool](https://discourse.aurelia.io/u/avrahamcool)\
**Post date:** [September 6, 2018, 4:46pm UTC](https://discourse.aurelia.io/t/detached-not-firing-in-composed-view/1559/4 "2018-09-06T16:46:47Z")

</div>

There is an issue for that,  
it’s syays there that deactivate is never called.

> <https://github.com/aurelia/templating-resources/issues/138>
