Webcom Android SDK Public API Reference / com.orange.webcom.sdkv2.datasync / TransactionOperation / toggle

toggle

@JvmStatic @JvmOverloads fun toggle(defaultValue: Boolean = false): (DatasyncValuable) -> TransactionOperation

Transaction function that atomically toggles the value of a boolean data node.

If the data node is not set it sets the defaultValue, if the data node has a non boolean value it aborts the transaction. This function is expected to be passed to the DatasyncNode.runTransaction method.

inline fun <reified T : Any> toggle(ping: T, pong: T): (DatasyncValuable) -> TransactionOperation

Transaction function that atomically toggles the value of a data node between 2 values ping and pong.

If the data node is not set it sets the ping value, if the data node has a value that is not of type T it aborts the transaction. This function is expected to be passed to the DatasyncNode.runTransaction method.