StaticcreateCreates a new instance of LayoutWatcher with the given LayoutWatcherConfig. It does not save it for future reuse.
Optionalconfig: LayoutWatcherConfigStaticreuseReturns an existing instance of LayoutWatcher with the given LayoutWatcherConfig, or creates a new one.
NOTE: It saves it for future reuse, so don't use this for temporary short-lived watchers.
Optionalconfig: LayoutWatcherConfigReadonlyfetchGet the current screen layout.
ReadonlyoffRemoves a previously added handler.
ReadonlyonCall the given handler whenever the layout changes.
Unless OnLayoutOptions.skipInitial is true, the handler is also called (almost) immediately with the current layout.
IMPORTANT: The same handler can not be added multiple times, even if the options differ. If the handler has already been added, it is removed and re-added with the current options.
LisnUsageError If the options are invalid.
LayoutWatcher listens for changes in either the width or aspect ratio of the viewport or the given root.
It does not track resize events; rather it's built on top of IntersectionObserver.
It manages registered callbacks globally and reuses IntersectionObservers for more efficient performance.