Class PropertySubscriber<T>

java.lang.Object
com.inductiveautomation.ignition.designer.mvvm.PropertySubscriber<T>
Type Parameters:
T - The type of the value that will be emitted by the publisher.
All Implemented Interfaces:
Flow.Subscriber<SubmissionContext<T>>

public class PropertySubscriber<T> extends Object implements Flow.Subscriber<SubmissionContext<T>>
This class is used to subscribe to a PropertyPublisherReadOnly and consume the values emitted by the publisher.
  • Constructor Details

    • PropertySubscriber

      public PropertySubscriber(Consumer<T> onNextConsumer)
      This constructor is used when you don't need access to the subscription. This version of the constructor is used when you only need to consume the value emitted by the publisher.
      Parameters:
      onNextConsumer - The consumer that will be called when a new value is emitted.
    • PropertySubscriber

      public PropertySubscriber(BiConsumer<SubmissionContext<T>, T> onNextConsumer)
      This constructor is used when you don't need access to the subscription. This version of the constructor is used when you need to consume the value emitted by the publisher and the SubmissionContext that is associated with the emission.
      Parameters:
      onNextConsumer - The consumer that will be called when a new value is emitted.
    • PropertySubscriber

      public PropertySubscriber(Consumer<Flow.Subscription> subscriptionConsumer, BiConsumer<SubmissionContext<T>, T> onNextConsumer)
      This constructor is used when you want to have access to the created subscription so that you can cancel the subscription when needed.
      Parameters:
      subscriptionConsumer - The consumer that will be called when the subscription is created.
      onNextConsumer - The consumer that will be called when a new value is emitted.
  • Method Details

    • onSubscribe

      public void onSubscribe(Flow.Subscription subscription)
      Specified by:
      onSubscribe in interface Flow.Subscriber<T>
    • onNext

      public void onNext(SubmissionContext<T> value)
      Specified by:
      onNext in interface Flow.Subscriber<T>
    • onError

      public void onError(Throwable throwable)
      Specified by:
      onError in interface Flow.Subscriber<T>
    • onComplete

      public void onComplete()
      Specified by:
      onComplete in interface Flow.Subscriber<T>
    • create

      public static <T> PropertySubscriber<T> create(Consumer<Flow.Subscription> subscriptionConsumer, Consumer<T> processOnNextConsumer)
      Factory method for creating a subscriber that consumes each emitted value. Use this when you only care about the value itself and not the emission's metadata (state, stateText). If you need that metadata, use create(Consumer, BiConsumer) instead.
      Type Parameters:
      T - The type of value emitted by the publisher.
      Parameters:
      subscriptionConsumer - Called when the subscription is created; use it to hold a reference so the subscription can be canceled later.
      processOnNextConsumer - Called each time a new value is emitted.
      Returns:
      A subscriber that delivers each emitted value to the consumer.
    • createNullable

      public static <T> PropertySubscriber<@Nullable T> createNullable(Consumer<Flow.Subscription> subscriptionConsumer, Consumer<@Nullable T> processOnNextConsumer)
      Factory method for subscribing to a publisher that may emit null values (i.e., one configured with PropertyPublisher.Mode.ALLOW_NULL).

      Use this instead of create(Consumer, Consumer) when the publisher can produce null.

      Type Parameters:
      T - The type of value emitted by the publisher (may be null).
      Parameters:
      subscriptionConsumer - Called when the subscription is created; use it to hold a reference so the subscription can be canceled later.
      processOnNextConsumer - Called each time a new value (including null) is emitted.
      Returns:
      A subscriber that safely handles null emissions.
    • create

      public static <T> PropertySubscriber<T> create(Consumer<Flow.Subscription> subscriptionConsumer, BiConsumer<SubmissionContext<T>, T> processOnNextConsumer)
      Factory method for creating a subscriber that also receives the SubmissionContext alongside each emitted value. Use this over create(Consumer, Consumer) when you need the emission's metadata — its state and stateText — to drive conditional UI behavior (e.g. showing warnings or clearing error text).
      Type Parameters:
      T - The type of value emitted by the publisher.
      Parameters:
      subscriptionConsumer - Called when the subscription is created; use it to hold a reference so the subscription can be canceled later.
      processOnNextConsumer - Called each time a new value is emitted, receiving both the SubmissionContext and the unwrapped value.
      Returns:
      A subscriber that provides context metadata on each emission.
    • createNullable

      public static <T> PropertySubscriber<@Nullable T> createNullable(Consumer<Flow.Subscription> subscriptionConsumer, BiConsumer<SubmissionContext<@Nullable T>, @Nullable T> processOnNextConsumer)
      Factory method combining the nullable variant with context metadata access. Use this when the publisher may emit null (i.e., configured with PropertyPublisher.Mode.ALLOW_NULL) and you also need the emission's state and stateText.
      Type Parameters:
      T - The type of value emitted by the publisher (may be null).
      Parameters:
      subscriptionConsumer - Called when the subscription is created; use it to hold a reference so the subscription can be canceled later.
      processOnNextConsumer - Called each time a new value (including null) is emitted, receiving both the SubmissionContext and the unwrapped (possibly null) value.
      Returns:
      A subscriber that handles null emissions and provides context metadata.