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>>
This class is used to subscribe to a
PropertyPublisherReadOnly and consume the values
emitted by the publisher.-
Constructor Summary
ConstructorsConstructorDescriptionPropertySubscriber(BiConsumer<SubmissionContext<T>, T> onNextConsumer) This constructor is used when you don't need access to the subscription.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.PropertySubscriber(Consumer<T> onNextConsumer) This constructor is used when you don't need access to the subscription. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> PropertySubscriber<T> create(Consumer<Flow.Subscription> subscriptionConsumer, BiConsumer<SubmissionContext<T>, T> processOnNextConsumer) Factory method for creating a subscriber that also receives theSubmissionContextalongside each emitted value.static <T> PropertySubscriber<T> create(Consumer<Flow.Subscription> subscriptionConsumer, Consumer<T> processOnNextConsumer) Factory method for creating a subscriber that consumes each emitted value.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.static <T> PropertySubscriber<@Nullable T> createNullable(Consumer<Flow.Subscription> subscriptionConsumer, Consumer<@Nullable T> processOnNextConsumer) Factory method for subscribing to a publisher that may emitnullvalues (i.e., one configured withPropertyPublisher.Mode.ALLOW_NULL).voidvoidvoidonNext(SubmissionContext<T> value) voidonSubscribe(Flow.Subscription subscription)
-
Constructor Details
-
PropertySubscriber
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
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 theSubmissionContextthat 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
- Specified by:
onSubscribein interfaceFlow.Subscriber<T>
-
onNext
- Specified by:
onNextin interfaceFlow.Subscriber<T>
-
onError
- Specified by:
onErrorin interfaceFlow.Subscriber<T>
-
onComplete
public void onComplete()- Specified by:
onCompletein interfaceFlow.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, usecreate(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 emitnullvalues (i.e., one configured withPropertyPublisher.Mode.ALLOW_NULL).Use this instead of
create(Consumer, Consumer)when the publisher can producenull.- Type Parameters:
T- The type of value emitted by the publisher (may benull).- 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 (includingnull) is emitted.- Returns:
- A subscriber that safely handles
nullemissions.
-
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 theSubmissionContextalongside each emitted value. Use this overcreate(Consumer, Consumer)when you need the emission's metadata — itsstateandstateText— 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 theSubmissionContextand 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 emitnull(i.e., configured withPropertyPublisher.Mode.ALLOW_NULL) and you also need the emission'sstateandstateText.- Type Parameters:
T- The type of value emitted by the publisher (may benull).- 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 (includingnull) is emitted, receiving both theSubmissionContextand the unwrapped (possibly null) value.- Returns:
- A subscriber that handles
nullemissions and provides context metadata.
-