ripe / com.ripe.android.base / Interactable

Interactable

open class Interactable : Observable

An entity that reactively represents a Ripe instance.

Constructors

<init>

Interactable(owner: Ripe, options: Map<String, Any>?)

An entity that reactively represents a Ripe instance.

Properties

options

open val options: Map<String, Any>?

A map with options to configure the instance.

owner

open val owner: Ripe

The ripe instance that will be represented.

Inherited Properties

callbacks

val callbacks: MutableMap<String, MutableList<ObservableCallback>>

A dictionary that contains all methods to be executed when an event is triggered

Functions

deinit

open fun deinit(): Unit

This method is called by the owner when it is deinitializing so that any necessary cleanup operations can be executed.

update

open fun update(state: Map<String, Any>): Unit

This method is called by the owner whenever its state changes so that the instance can update itself for the new state.

Inherited Functions

addCallback

fun addCallback(event: String, callback: ObservableCallback): ObservableCallback

Binds to an event by providing a block that will receive the event payload as a parameter and return a Deferred that will be completed asynchronously.

bind

fun bind(event: String, callback: (args: Map<String, Any>) -> Unit): ObservableCallback

Binds to an event by providing a block that will receive the event payload as a parameter. The block will be executed synchronously, for costly operations prefer the use of bindAsync.

bindAsync

fun bindAsync(event: String, callback: ObservableCallback): ObservableCallback

Binds to an event by providing a block that will receive the event payload as a parameter and return a Deferred that will be completed asynchronously.

bindSync

fun bindSync(event: String, callback: (args: Map<String, Any>) -> Unit): ObservableCallback

Binds to an event by providing a block that will receive the event payload as a parameter. The block will be executed synchronously, for costly operations prefer the use of bindAsync.

removeCallback

fun removeCallback(event: String, callback: ObservableCallback?): Unit

Unbinds the provided callback from an event.

runCallbacks

fun runCallbacks(event: String, args: Map<String, Any> = HashMap()): Deferred<List<Any?>>

Triggers the event by calling all its bound callbacks with args as parameters.

trigger

fun trigger(event: String, args: Map<String, Any> = HashMap()): Deferred<List<Any?>>

Triggers the event by calling all its bound callbacks with args as parameters.

unbind

fun unbind(event: String, callback: ObservableCallback?): Unit

Unbinds the provided callback from an event.

Inheritors

Visual

open class Visual : Interactable

This is a superclass for visual representations of a Ripe instance.