forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🤖 Merge PR DefinitelyTyped#71578 phoenix_live_view 1.0, metadata Live…
…Socket option by @pzingg
- Loading branch information
Showing
12 changed files
with
832 additions
and
457 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
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,36 @@ | ||
import LiveSocket from "./live_socket"; | ||
|
||
export type OnReply = (reply: any, ref: number) => any; | ||
export type CallbackRef = (customEvent: any, bypass: boolean) => string; | ||
|
||
export interface ViewHookInterface { | ||
el: HTMLElement; | ||
liveSocket: LiveSocket; | ||
|
||
mounted?: () => void; | ||
updated?: () => void; | ||
beforeUpdate?: () => void; | ||
destroyed?: () => void; | ||
reconnected?: () => void; | ||
disconnected?: () => void; | ||
|
||
js(): object; | ||
pushEvent(event: string, payload: any, onReply?: OnReply): any; | ||
pushEventTo(phxTarget: any, event: string, payload: object, onReply?: OnReply): any; | ||
handleEvent(event: string, callback: any): CallbackRef; | ||
removeHandleEvent(callbackRef: CallbackRef): void; | ||
upload(name: any, files: any): any; | ||
uploadTo(phxTarget: any, name: any, files: any): any; | ||
} | ||
|
||
export interface Hook<T extends object = {}> { | ||
mounted?: (this: T & ViewHookInterface) => void; | ||
beforeUpdate?: (this: T & ViewHookInterface) => void; | ||
updated?: (this: T & ViewHookInterface) => void; | ||
beforeDestroy?: (this: T & ViewHookInterface) => void; | ||
destroyed?: (this: T & ViewHookInterface) => void; | ||
disconnected?: (this: T & ViewHookInterface) => void; | ||
reconnected?: (this: T & ViewHookInterface) => void; | ||
} | ||
|
||
export type HooksOptions = Record<string, Hook<any>>; |
Oops, something went wrong.