@wocart/theme / lifecycle / bindEach
Function: bindEach()
bindEach<
T>(selector,bind,options?): () =>void
Runs bind once on every element selector matches: when the page is
ready, after Astro's router swaps a page in, and after an editor's preview
swaps a section in. A bind may return a teardown, run when its element
leaves — before Astro swaps the page out, or when a later pass finds the
element gone. Returns a function that stops it and runs every teardown.
Code
Type Parameters
T
T extends Element = HTMLElement
Parameters
selector
string
bind
(element) => Teardown
options?
Returns
() => void