GuestProtocolAdapter

abstract class GuestProtocolAdapter(hostVersion: RedwoodVersion) : EventSink

Connects the guest (composition) of a Redwood UI to the host of that UI.

Guest widgets use this to send view tree updates to the host, and to receive user events from the host.

This interface is for generated code use only.

Constructors

Link copied to clipboard
constructor(hostVersion: RedwoodVersion)

Properties

Link copied to clipboard
abstract val json: Json
Link copied to clipboard
abstract val root: Widget.Children<Unit>

The root of the widget tree onto which widgetSystem-produced widgets can be added. Changes to this instance are recorded as changes to Id.Root and ChildrenTag.Root.

Link copied to clipboard

Host versions prior to 0.10.0 contained a bug where they did not recursively remove widgets from the protocol map which leaked any child views of a removed node. We can work around this on the guest side by synthesizing removes for every node in the subtree.

Link copied to clipboard

The provider of factories of widgets which record property changes and whose children changes are also recorded. You must attach returned widgets to root or the children of a widget in the tree beneath root in order for it to be tracked.

Functions

Link copied to clipboard
abstract fun appendAdd(id: Id, tag: ChildrenTag, index: Int, child: ProtocolWidget)
Link copied to clipboard
abstract fun appendCreate(id: Id, tag: WidgetTag)
Link copied to clipboard
abstract fun appendModifierChange(id: Id, value: Modifier)
Link copied to clipboard
abstract fun appendMove(id: Id, tag: ChildrenTag, fromIndex: Int, toIndex: Int, count: Int)
Link copied to clipboard
abstract fun appendPropertyChange(id: Id, widgetTag: WidgetTag, propertyTag: PropertyTag, value: Boolean)
abstract fun <T> appendPropertyChange(id: Id, widgetTag: WidgetTag, propertyTag: PropertyTag, serializer: KSerializer<T>, value: T)

abstract fun appendPropertyChange(id: Id, widgetTag: WidgetTag, propertyTag: PropertyTag, value: UInt)

There's a bug in kotlinx.serialization where decodeFromDynamic() is broken for UInt values larger than MAX_INT. For example, 4294967295 is incorrectly encoded as -1. We work around that here by special casing that type.

Link copied to clipboard
abstract fun appendRemove(id: Id, tag: ChildrenTag, index: Int, count: Int, removedIds: List<Id>)
Link copied to clipboard
abstract fun emitChanges()

Write changes to the underlying ChangesSink. This function may no-op if there are no changes to send.

Link copied to clipboard
abstract fun initChangesSink(changesSink: ChangesSink)
Link copied to clipboard
abstract fun nextId(): Id
Link copied to clipboard
abstract fun removeWidget(id: Id)
Link copied to clipboard
abstract fun sendEvent(event: Event)