class Ripe : Observable
Represents a customizable model. The options map supports the following keys:
Ripe(brand: String?, model: String?, options: Map<String, Any> = HashMap())
Creates a Ripe instance with the provided brand, model and options. |
var api: RipeAPI
The API instance to be used. |
|
var brand: String?
The brand of the model. |
|
var country: String?
The country where the model will be delivered. |
|
var currency: String?
The currency to use when calculating the price. |
|
var engraving: String
The current engraving of the model. |
|
var flag: String?
A specific attribute of the model. |
|
var initials: String
The current initials of the model. |
|
var loadedConfig: Map<String, Any>?
The configuration information of the current model. |
|
var locale: String?
The default locale to use when localizing values. |
|
var model: String?
The name of the model. |
|
var options: MutableMap<String, Any>
A map with options to customise the Ripe instance. |
|
var parts: MutableMap<String, Any>
The current customisation of the model. |
|
var ready: Boolean
If the instance is ready for interactions. |
|
var variant: String?
The variant of the model. |
|
var version: String?
The version of the build in use. |
val callbacks: MutableMap<String, MutableList<ObservableCallback>>
A dictionary that contains all methods to be executed when an event is triggered |
fun addPlugin(plugin: Plugin): Unit
Registers a plugin to this Ripe instance. |
|
fun bindImage(view: ImageView, options: Map<String, Any> = HashMap()): Image
Binds an Image to this Ripe instance. |
|
fun bindInteractable(child: Interactable): Interactable
Binds an Interactable to this Ripe instance. |
|
fun canRedo(): Boolean
Indicates if there are part changes to redo. |
|
fun canUndo(): Boolean
Indicates if there are part changes to undo. |
|
fun cloneParts(parts: Map<String, Any>): Map<String, Any> |
|
suspend fun config(brand: String?, model: String?, options: Map<String, Any> = HashMap()): Unit
Sets the model to be customised. |
|
fun deselectPart(part: String, options: Map<String, Any> = HashMap()): Unit
Deselects a part of the model. Triggers a "deselected_part" event with the part. |
|
fun getPartsCopy(): Map<String, Any>
Retrieves a copy of the current customization. |
|
suspend fun isReady(): Boolean?
Verifies if the current ripe instance is ready (properly loaded) and if not blocks until it becomes ready. |
|
fun redo(): Unit
Reapplies the last change to the parts that was undone. Notice that if there's a change when the history pointer is in the middle of the stack the complete stack forward is removed (history re-written). |
|
fun removePlugin(plugin: Plugin): Unit
Unregisters a plugin to this Ripe instance. |
|
fun selectPart(part: String, options: Map<String, Any> = HashMap()): Unit
Selects a part of the model. Triggers a "selected_part" event with the part. |
|
fun setInitials(initials: String, engraving: String, noUpdate: Boolean = false): Unit
Changes the personalization of the model. |
|
fun setPart(part: String, material: String?, color: String?, noEvents: Boolean = false, options: Map<String, Any> = HashMap()): Unit
Changes the customization of a part. |
|
fun setParts(parts: Any, noEvents: Boolean = false, options: Map<String, Any> = HashMap()): Unit
Allows changing the customization of a set of parts in bulk. |
|
fun unbindImage(image: Image): Unit
Unbinds an Image from this Ripe instance. |
|
fun unbindInteractable(child: Interactable): Unit
Unbinds an Interactable from this Ripe instance. |
|
fun undo(): Unit
Reverses the last change to the parts. It is possible to undo all the changes done from the initial state. |
|
fun update(state: Map<String, Any> = this._getState()): Unit
Triggers the update of the children so that they represent the current state of the model. |
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. |
|
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 |
|
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. |
|
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 |
|
fun removeCallback(event: String, callback: ObservableCallback?): Unit
Unbinds the provided callback from an event. |
|
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. |
|
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. |
|
fun unbind(event: String, callback: ObservableCallback?): Unit
Unbinds the provided callback from an event. |
|
suspend fun waitForEvent(event: String): Any
Waits for a certain event to occurs suspending the current coroutine until the event is triggered. |