Allow passthrough of other options to the Phoenix Socket constructor.
OptionalbindingThe optional prefix to use for all phx DOM annotations.
Defaults to "phx-".
OptionalblockIf set to true, phx-change events will be blocked (will not fire)
while the user is composing input using an IME (Input Method Editor).
This is determined by the e.isComposing property on keyboard events,
which is true when the user is in the process of entering composed characters (for example,
when typing Japanese or Chinese using romaji or pinyin input methods).
By default, phx-change will not be blocked during a composition session,
but note that there were issues reported in older versions of Safari,
where a LiveView patch to the input caused unexpected behavior.
For more information, see
Defaults to false.
OptionaldefaultsDefaults for phx-debounce and phx-throttle.
Optionaldebounce?: numberThe millisecond phx-debounce time. Defaults to 300.
Optionalthrottle?: numberThe millisecond phx-throttle time. Defaults to 300.
OptionaldisconnectedDelay in milliseconds before executing phx-disconnected commands.
OptionaldomDOM callbacks.
OptionaljsQuerySelectorAll?: (An optional function to modify the behavior of querying elements in JS commands.
OptionalonBeforeElUpdated?: (fromEl: Element, toEl: Element) => voidCalled before an element is updated.
OptionalonDocumentPatch?: (start: () => void) => voidWhen defined, called with a start callback that needs to be called to perform the actual patch. Failing to call the start callback causes the page to become stuck.
This can be used to delay patches in order to perform view transitions, for example:
let liveSocket = new LiveSocket("/live", Socket, {
dom: {
onDocumentPatch(start) {
document.startViewTransition(start);
}
}
})
It is strongly advised to call start as quickly as possible.
OptionalonNodeAdded?: (node: Node) => voidCalled when a new DOM node is added.
OptionalonPatchEnd?: (container: HTMLElement) => voidCalled immediately after a DOM patch is applied.
OptionalonPatchStart?: (container: HTMLElement) => voidCalled immediately before a DOM patch is applied.
OptionalfailsafeTime between reload attempts in failsafe mode.
OptionalhooksCallbacks for LiveView hooks.
See Client hooks via phx-hook for more information.
OptionalloaderDelay in milliseconds before applying loading states.
OptionallocalAn optional Storage-compatible object.
Useful when LiveView won't have access to localStorage.
See sessionStorage for an example.
OptionalmaxMaximum reloads before entering failsafe mode.
OptionalmetadataObject mapping event names to functions for populating event metadata.
metadata: {
click: (e, el) => {
return {
ctrlKey: e.ctrlKey,
metaKey: e.metaKey,
detail: e.detail || 1,
}
},
keydown: (e, el) => {
return {
key: e.key,
ctrlKey: e.ctrlKey,
metaKey: e.metaKey,
shiftKey: e.shiftKey
}
}
}
OptionalparamsAn object or function for passing connect params. The function receives the element associated with a given LiveView. For example:
(el) => {view: el.getAttribute("data-my-view-name", token: window.myToken}
OptionalreloadMaximum time between normal reload attempts.
OptionalreloadMinimum time between normal reload attempts.
OptionalsessionAn optional Storage-compatible object.
Useful when LiveView won't have access to sessionStorage. For example, this could
happen if a site loads a cross-domain LiveView in an iframe.
Example usage:
class InMemoryStorage {
constructor() { this.storage = {} }
getItem(keyName) { return this.storage[keyName] || null }
removeItem(keyName) { delete this.storage[keyName] }
setItem(keyName, keyValue) { this.storage[keyName] = keyValue }
}
OptionaluploadersCallbacks for LiveView uploaders.
OptionalviewFunction to log debug information. For example:
(view, kind, msg, obj) => console.log(`${view.id} ${kind}: ${msg} - `, obj)
Options for configuring the LiveSocket instance.