ripe / com.ripe.android.base / Observable

Observable

open class Observable

An object that emits events. Listeners can bind to specific events and be notified when the event is triggered.

Constructors

<init>

Observable()

An object that emits events. Listeners can bind to specific events and be notified when the event is triggered.

Properties

callbacks

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

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

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

Interactable

open class Interactable : Observable

An entity that reactively represents a Ripe instance.

Plugin

open class Plugin : Observable

Base class of a Ripe Plugin.

Ripe

class Ripe : Observable

Represents a customizable model. The options map supports the following keys: