Fork me on GitHub
#hoplon
<
2017-03-30
>
alandipert01:03:51

@piotrek no, but i just realized, if you make a mutation observer for the parent element of a loop-tpl, oyu could receive events

alandipert01:03:03

at least, this is my yet-untested theory 😎 ™️

alandipert01:03:34

i think mutation observer API is deprecated/dead but still in many browsers

alandipert01:03:53

would be curious to see what you're doing that you want a removal event

alandipert01:03:52

hi fingertoe 👋

fingertoe01:03:45

Hello! I am pretty excited to use Hoplon in a couple of projects I am working on. Playing with it, I like it, and it seems pretty easy to understand!

alandipert01:03:10

cool! give a shout if you hit any snags

alandipert01:03:14

friendly group here

thedavidmeister04:03:38

@alandipert i think mutation observer api still works fine, there's an older event based mutation api that is deprecated

thedavidmeister04:03:29

actually i put a placeholder issue up at https://github.com/hoplon/hoplon/issues/176 if you want to discuss further @piotrek @alandipert

piotrek09:03:18

@alandipert, @thedavidmeister I was thinking about cases when I would like to integrate some heavyweight external component (e.g. google maps) which would be wrapped in my own element. Another scenario would be to create a standalone element which would create or start some background process and it should be cleaned up / stopped when the element is removed from the DOM. Maybe it should be achieved in a different way and this is a XY problem 🙂

thedavidmeister10:03:17

@piotrek for the latter, i've used a lens

thedavidmeister10:03:58

p (let [c (j/cell 0)]
          (h/do-watch c dirty!)
          (j/cell= c
           #(when-not @paused? (reset! c %))))

thedavidmeister10:03:03

out of context snippet 🙂 ^^

thedavidmeister10:03:54

if you're adding removing something with a when-tpl you can just use the same predicate cell for paused?

thedavidmeister11:03:02

i'm not 100% sure why you need to respond to google maps leaving the DOM

thedavidmeister11:03:54

if you want to pause/throttle/debounce cells for performance it's actually pretty easy and is probably best decoupled from the state of the DOM anyway

piotrek11:03:34

I would like for example to remove the google maps component completely so it does not occupy memory

piotrek11:03:46

Instead of just detach it or hide it

piotrek11:03:52

I was under impression that previously for example loop-tpl wasn’t removing/destroying the dom nodes but only detaching them and retaining them in a cache

piotrek11:03:59

But it looks like they are still created once and reused (but just detached from dom)

piotrek11:03:20

So that’s my concern - I would rather to remove them completely instead of detaching

thedavidmeister23:03:31

@piotrek @micha might have a suggestion for that