Function tokens::on_change

source ·
pub fn on_change<TToken, TProducer, TConsumer, TState>(
    producer: TProducer,
    consumer: TConsumer,
    state: Option<Arc<TState>>
) -> impl Subscription
where TState: 'static, TToken: ChangeToken + 'static, TProducer: Fn() -> TToken + Send + Sync + 'static, TConsumer: Fn(Option<Arc<TState>>) + Send + Sync + 'static,
Expand description

Registers a consumer action to be invoked whenever the token produced changes.

Arguments

  • producer - The function that produces the change token
  • consumer - The function that is called when the change token changes
  • state - The optional state supplied to the consumer

Returns

An opaque subscription. When it is dropped, the producer will no longer be polled and the consumer will no longer be notified.