-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #489 from player-ui/android-expose-constantsContro…
…ller Android/JVM - expose constantController
- Loading branch information
Showing
5 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
jvm/core/src/main/kotlin/com/intuit/playerui/core/constants/ConstantsController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.intuit.playerui.core.constants | ||
import com.intuit.playerui.core.bridge.Node | ||
import com.intuit.playerui.core.bridge.NodeWrapper | ||
import com.intuit.playerui.core.bridge.getInvokable | ||
import com.intuit.playerui.core.bridge.serialization.serializers.NodeWrapperSerializer | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable(with = ConstantsController.Serializer::class) | ||
public class ConstantsController(override val node: Node) : NodeWrapper { | ||
/** | ||
* Function to add constants to the providers store | ||
* @param data values to add to the constants store | ||
* @param namespace namespace to add the constants under | ||
*/ | ||
public fun addConstants(data: Map<String, Any>, namespace: String) { | ||
node.getInvokable<Unit>("addConstants")?.invoke(data, namespace) | ||
} | ||
|
||
/** | ||
* Function to retrieve constants from the providers store | ||
* @param key Key used for the store access | ||
* @param namespace namespace values were loaded under (defined in the plugin) | ||
* @param fallback Optional - if key doesn't exist in namespace what to return (will return unknown if not provided) | ||
*/ | ||
public fun getConstants(key: String, namespace: String, fallback: Any? = null): Any? { | ||
return node.getInvokable<Any?>("getConstants")?.invoke(key, namespace, fallback) | ||
} | ||
|
||
/** | ||
* Function to set values to temporarily override certain keys in the permanent store | ||
* @param data values to override store with | ||
* @param namespace namespace to override | ||
*/ | ||
public fun setTemporaryValues(data: Any, namespace: String) { | ||
node.getInvokable<Unit>("setTemporaryValues")?.invoke(data, namespace) | ||
} | ||
|
||
/** | ||
* Clears any temporary values that were previously set | ||
*/ | ||
public fun clearTemporaryValues() { | ||
node.getInvokable<Unit>("clearTemporaryValues")?.invoke() | ||
} | ||
|
||
internal object Serializer : NodeWrapperSerializer<ConstantsController>(::ConstantsController) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters