once

inline fun <T : SmartAccountEvent> once(crossinline listener: (T) -> Unit): () -> Unit

Subscribes to an event, but only triggers once.

The listener will be automatically unsubscribed after the first event. Useful for waiting for a single occurrence of an event.

Return

A function that unsubscribes the listener if called before the event fires

Example:

emitter.once<SmartAccountEvent.TransactionSubmitted> { event ->
println("First transaction submitted: ${event.hash}")
}

Parameters

T

The event type to subscribe to

listener

The callback function to invoke once