Expand description
A catch all for project-wide macros and general-purpose functions that are not directly related to Perspective.
Modules below crate::utils strive to be single-responsibility, but some
reference other crate::utils modules when it helps reduce boiler-plate.
Structs§
- A pub/sub struct which allows many listeners to subscribe to many publishers, without leaking callbacks as listeners are dropped.
- Like a
PubSubwithoutPubSub::emit; the reciprocal ofPubSub::callback.Subscriberdoes not keep the parentPubSubalive. - Manages the lifetime of a listener registered to a
PubSub<T>by deregistering the associated listener when dropped. - A mutable reference for capturing the
Scope<_>props arguments, a useful function for tests.
Traits§
- Utilities for caret position. DOM elements have different APIs for this but
Derefmakes them fall through, so it is important that this method be called on the correct struct type! - Blur the current active elemnt, triggering any blur handlers in the application (e.g. modals). This is often necessary when a DOM update will invalidate something that has a
"blur"event handler. - Trait for polymorphic return value via turbofish-const-generic syntax.
Functions§
- An
asyncwhich awaits the browser’sloadevent, which is automatically bypassed ifdocument.readyStateindicates this has already occurred. - An
asyncversion ofrequestAnimationFrame(), which resolves on the next animation frame. - An
asyncversion ofset_timeout, which resolves intimeoutmilliseconds