new DOMObserver()

Description

Representation of a MutationObserver but with helpful utilities.

Methods


subscribeToQuerySelector( callback, filter, bind, group ) → {Object}

Description

Subscribes to mutations that affect an element matching a selector.

Parameters
Name Type Description
callback function

A function to call when on a mutation

filter function

A function to call to filter mutations

bind Any

Something to bind the callback to

group Boolean

Whether to call the callback with an array of mutations instead of a single mutation

Returns

observe()

Description

Starts observing the element. This will be called when attaching a callback. You don't need to call this manually.


disconnect()

Description

Disconnects this observer. This stops callbacks being called, but does not unbind them. You probably want to use observer.unsubscribeAll instead.


subscribe( callback, filter, bind, group ) → {Object}

Description

Subscribes to mutations.

Parameters
Name Type Description
callback function

A function to call when on a mutation

filter function

A function to call to filter mutations

bind Any

Something to bind the callback to

group Boolean

Whether to call the callback with an array of mutations instead of a single mutation

Returns

unsubscribe( subscription )

Description

Removes a subscription and disconnect if there are none left.

Parameters
Name Type Description
subscription Object

A subscription object returned by observer.subscribe