Package 

Class ViewModelInstance

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    
    public final class ViewModelInstance
     implements AutoCloseable
                        

    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.

    • Method Detail

      • getNumberFlow

         final Flow<Float> getNumberFlow(String propertyPath)

        Creates or retrieves from cache a number property, represented as a cold Flow.

        The flow is subscribed to updates from the command queue while it is being collected.

        This flow emits every distinct value (up to the backing buffer limit). If you process the flow slowly, consider applying conflate if you only need the latest value to skip intermediate values. Alternatively, if you need to process every value, consider using a buffer operator with an appropriate buffer size to handle bursts.

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

         final Flow<String> getStringFlow(String propertyPath)

        Creates or retrieves from cache a string property, represented as a cold Flow.

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

         final Flow<Boolean> getBooleanFlow(String propertyPath)

        Creates or retrieves from cache a boolean property, represented as a cold Flow.

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

         final Flow<String> getEnumFlow(String propertyPath)

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

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

         final Flow<Integer> getColorFlow(String propertyPath)

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

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

         final Flow<Unit> getTriggerFlow(String propertyPath)

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

        The flow is subscribed to updates from the command queue while it is being collected.

        Parameters:
        propertyPath - The path to the trigger property from this view model instance.
      • 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.