Docs · API reference · Verso.Abstractions

ILayoutLifecycleHandler Interface#

Capability interface for extensions that need per-mount lifecycle callbacks for a layout owned by the same extension. Implement alongside an ILayoutEngine on the same class (the common case) or as a sibling class that shares the layout's LayoutId. Routing is by the (ExtensionId, LayoutId) identity pair.

public interface ILayoutLifecycleHandler : Verso.Abstractions.IExtension

Implements IExtension

Remarks#

Primarily relevant to Isolated layouts, which own client-side state the host cannot see and therefore need callbacks for "frame is alive" and "frame is going away." Inline layouts may implement the interface to receive per-mount notifications or to push out-of-band updates without waiting for an interaction. Layouts that do not implement this interface incur no overhead.

Properties#

LayoutId Property#

The LayoutId this handler services. The handler's ExtensionId supplies the other half of the identity pair. The handler's owning extension must also register an ILayoutEngine with this same LayoutId.

string LayoutId { get; }

Property Value#

System.String

Methods#

OnRendererMountedAsync(LayoutRendererMountContext) Method#

Invoked after a renderer instance has signaled readiness and before the host completes its initialization handshake. The returned read-only dictionary is merged into the host's init payload, giving the renderer authoritative initial state. The host only reads the entries, so a plain System.Collections.Generic.Dictionary<> is an acceptable return value. Use the supplied Frame to push later messages while the renderer is alive.

System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyDictionary<string,object>?> OnRendererMountedAsync(Verso.Abstractions.LayoutRendererMountContext context);

Parameters#

context LayoutRendererMountContext

Returns#

System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyDictionary<System.String,System.Object>>

OnRendererUnmountedAsync(LayoutRendererUnmountContext) Method#

Invoked when a renderer instance is being torn down (notebook close, layout switch, kernel restart, manual remount). Cancel subscriptions and release per-frame resources. The frame channel obtained from the matching mount context is already marked dead before this method is invoked and becomes invalid after the method returns.

System.Threading.Tasks.Task OnRendererUnmountedAsync(Verso.Abstractions.LayoutRendererUnmountContext context);

Parameters#

context LayoutRendererUnmountContext

Returns#

System.Threading.Tasks.Task