EquivalentEventLambda

class EquivalentEventLambda<E, R>(eventHandler: EventHandler<E>, returnsUnit: Boolean) : Function1<E, R>

A Function1 event lambda that is backed by a real EventHandler, so that lambda-shaped event handlers behave exactly like the ones produced by the generated non-lambda on<Event>(c) factory.

The generated *AsLambda factories used to allocate a fresh anonymous Function1 that closed over the owning component/section instance (_ref) and its ComponentContext. That has two problems: the fresh lambda is never structurally equal to the previous render's (breaking equivalence and forcing redundant re-resolves), and — more importantly — a reused lambda would dispatch against the captured, now-stale @Prop/@State/context snapshot.

This wrapper captures nothing render-specific. It holds the EventHandler created by the sibling on<Event>(c) factory and delegates to it for both behaviors:

The result is that a lambda returned by *AsLambda is equivalence-stable across renders and always dispatches against the current owner — identical to a plain EventHandler.

Parameters

eventHandler

the real handler from the on<Event>(c) factory; the single source of truth for dispatch and equivalence.

returnsUnit

whether the underlying event method returns Unit (void); when true invoke returns Unit rather than the dispatch result (which is null for void events).

Constructors

Link copied to clipboard
constructor(eventHandler: EventHandler<E>, returnsUnit: Boolean)

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open operator override fun invoke(event: E): R