Skip to main content

movable

Function movable 

Source
pub fn movable<K: Hash>(key: K, content: impl FnOnce())
Expand description

Composes content under an identity that is key alone, the same at every call site, so the subtree can be emitted from any parent and keep its remembered values, its running effects and its nodes.

Move content by emitting it under a different parent, in the same pass or a later one: when the old parent stops emitting it, the subtree is retained under key; when a parent emits it, the retained subtree is taken back. A site that asks for content still attached elsewhere composes nothing and is recomposed once the content is retained, so the order in which the two parents recompose does not matter.

Content is shown at most once. Two live sites with the same key leave the later one empty. Retained content is kept until a parent takes it back or forget_movable releases it, so an item the app closes for good must be forgotten or its state stays in memory. A subtree may cross into and out of a SubcomposeLayout slot, whose content lives in a slot table of its own: the table that held it gives up its anchors and the one taking it over issues new ones.