2

I am trying to wrap my head around how exactly ownerships works in scala.rx. At the moment I have a Scala.js web application that just imports rx.Ctx.Owner.Unsafe._ wherever I am using Rxs. This - however - leads to the creation of a lot of detached DOM elements because this unsafe global owner keeps a reference to all Rxs ever created and never lets them go. That way, all DOM elements that I am creating using scalatags and scalatags-rx remain in my application as detached elements forever.

What I would like to do now is to create one implicit val pageOwner: Ctx.Owner = Ctx.Owner.safe() for every one of my application's pages and once navigating away from this page, I would like to somehow kill() all Rxs owned by this owner so they can be garbage collected. There is no kill() method defined on Ctx.Owner, so I have been wondering if garbage collection would work if the owner itself is garbage collected.

Florian Baierl
  • 2,378
  • 3
  • 25
  • 50

0 Answers0