This repository has been archived by the owner on May 23, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
export default class SelectorObserver { | ||
constructor(rootNode: Node) | ||
disconnect(): void | ||
observe: typeof observe | ||
} | ||
|
||
export declare function observe<T extends Element>( | ||
selector: string, | ||
options: { | ||
constructor: {new (): T} | ||
} & Options<T> | ||
): Observer | ||
export declare function observe<T extends Element>( | ||
options: { | ||
selector: string | ||
constructor: {new (): T} | ||
} & Options<T> | ||
): Observer | ||
export declare function observe(selector: string, initialize: InitializerCallback<Element>): Observer | ||
export declare function observe(selector: string, options: Options<Element>): Observer | ||
export declare function observe(options: {selector: string} & Options<Element>): Observer | ||
|
||
type Options<T> = { | ||
initialize?: InitializerCallback<T> | ||
add?: AddCallback<T> | ||
remove?: RemoveCallback<T> | ||
subscribe?: SubscribeCallback<T> | ||
} | ||
|
||
type InitializerCallback<T> = (el: T) => void | InitializerCallbacks<T> | ||
type AddCallback<T> = (el: T) => void | ||
type RemoveCallback<T> = (el: T) => void | ||
type SubscribeCallback<T> = (el: T) => Subscription | ||
|
||
type InitializerCallbacks<T> = { | ||
add?: AddCallback<T> | ||
remove?: RemoveCallback<T> | ||
} | ||
|
||
type Observer = { | ||
abort(): void | ||
} | ||
|
||
interface Subscription { | ||
unsubscribe(): void | ||
} |