Package 

Class ViewModelInstance


  • 
    public final class ViewModelInstance
    
                        

    A view model instance for data binding which has properties that can be set and observed.

    The instance must be bound to a state machine for its values to take effect. This is done by passing it to RiveUI.

    • Constructor Detail

      • ViewModelInstance

        ViewModelInstance(ViewModelInstanceHandle instanceHandle, CommandQueue commandQueue, CoroutineScope parentScope)
        Parameters:
        instanceHandle - The handle to the view model instance on the command server.
        commandQueue - The command queue that owns the view model instance.
        parentScope - The coroutine scope to use for launching coroutines.
    • Method Detail

      • getNumberFlow

         final StateFlow<Float> getNumberFlow(String propertyPath, Float initialValue)

        Creates or retrieve from cache a number property, represented as a StateFlow.

        The flow will automatically subscribe to updates from the command queue.

        Parameters:
        propertyPath - The path to the property from this view model instance.
        initialValue - The initial value of the property.
      • getStringFlow

         final StateFlow<String> getStringFlow(String propertyPath, String initialValue)

        Creates or retrieve from cache a string property, represented as a StateFlow.

        The flow will automatically subscribe to updates from the command queue.

        Parameters:
        propertyPath - The path to the property from this view model instance.
        initialValue - The initial value of the property.
      • getBooleanFlow

         final StateFlow<Boolean> getBooleanFlow(String propertyPath, Boolean initialValue)

        Creates or retrieve from cache a boolean property, represented as a StateFlow.

        The flow will automatically subscribe to updates from the command queue.

        Parameters:
        propertyPath - The path to the property from this view model instance.
        initialValue - The initial value of the property.
      • getEnumFlow

         final StateFlow<String> getEnumFlow(String propertyPath, String initialValue)

        Creates or retrieve from cache an enum property, represented as a StateFlow. Enums are represented as strings, and this flow will emit the string value of the enum.

        The flow will automatically subscribe to updates from the command queue.

        Parameters:
        propertyPath - The path to the property from this view model instance.
        initialValue - The initial value of the property.
      • getColorFlow

         final StateFlow<Integer> getColorFlow(String propertyPath, @ColorInt() Integer initialValue)

        Creates or retrieve from cache a color property, represented as a StateFlow. Colors are represented as AARRGGBB integers, and this flow will emit the integer value of the color.

        The flow will automatically subscribe to updates from the command queue.

        Parameters:
        propertyPath - The path to the property from this view model instance.
        initialValue - The initial value of the property.
      • getTriggerFlow

         final StateFlow<Unit> getTriggerFlow(String propertyPath)

        Creates or retrieve from cache a trigger property, represented as a StateFlow. Triggers emit Unit as the value, which simply indicates that the trigger has been fired.

      • setNumber

         final Unit setNumber(String propertyPath, Float value)

        Sets a number property on this view model instance.

        Parameters:
        propertyPath - The path to the property from this view model instance.
        value - The value to set the property to.
      • setString

         final Unit setString(String propertyPath, String value)

        Sets a string property on this view model instance.

        Parameters:
        propertyPath - The path to the property from this view model instance.
        value - The value to set the property to.
      • setBoolean

         final Unit setBoolean(String propertyPath, Boolean value)

        Sets a boolean property on this view model instance.

        Parameters:
        propertyPath - The path to the property from this view model instance.
        value - The value to set the property to.
      • setEnum

         final Unit setEnum(String propertyPath, String value)

        Sets an enum property on this view model instance. Enums are represented as strings.

        Parameters:
        propertyPath - The path to the property from this view model instance.
        value - The string value of the enum to set the property to.
      • setColor

         final Unit setColor(String propertyPath, @ColorInt() Integer value)

        Sets a color property on this view model instance. Colors are represented as AARRGGBB integers.

        Parameters:
        propertyPath - The path to the property from this view model instance.
        value - The integer value of the color to set the property to.
      • fireTrigger

         final Unit fireTrigger(String propertyPath)

        Fires a trigger on this view model instance.

        Parameters:
        propertyPath - The path to the trigger property from this view model instance.