Any way to know if a modifier has been removed? li...
# compose
a
Any way to know if a modifier has been removed? like
DisposableEffect
but for modifiers. I am implementing a Drag and Drop Modifier and I am keeping track of each target's coordinates in an object. I would like to delete those coords/'unregister' them when the composable is no longer in the composition
I think I can do this via
Modifier.composed{}
. just spotted
l
composed
is generally discouraged. If you are using modifier.node APIs you can use
onDetach
to manage logic here. Or you could just make your modifier factory function
@Composable
, and add
DisposableEffect
there
a
why is
composed
discouraged? marking my modifier with
@Composable
felt like a code smell to me
l
In any case making a modifier node implementation is probably the best thing here
a
thanks for the link. i think u are right
will mark with Composable for now. too little time to understand the nodes api rn