observeResize
projects/common/layout/observers/resize-signal.ts
Description#
Subscribes apply to size changes of element on host.
Re-applies on every observation and returns the teardown that disconnects
the observer. On a host without ResizeObserver (SSR, jsdom) nothing is
wired, apply never fires, and the returned teardown is a no-op. Unlike the
media-query twin there is no synchronous seed: the first size is whatever the
observer reports after the next layout.
Reach for this low-level form when the observed element or the box model is
reactive and the subscription must follow it (re-wire per effect run via
onCleanup); for a static target, createResizeSignal owns the
teardown via DestroyRef.
Signature#
observeResize(host, element: Element, box: ResizeObserverBoxOptions, apply)Parameters#
The window-like object to read ResizeObserver from.
ElementThe element to observe.
ResizeObserverBoxOptionsWhich box model to report.
Receives the first entry of every observation batch.
Returns#
void Teardown that disconnects the observer.