async fn notify_on_change(
    mut change_receiver: UnboundedReceiver<LightData>,
    notifier: Arc<Mutex<dyn LightNotifier + Send + Sync>>,
    current_value: Arc<Mutex<LightData>>,
) -> AbortHandle {
    let (abort_handle, abort_registration) = AbortHandle::new_pair();

    fasync::Task::spawn(
        Abortable::new(
            async move {
                while let Some(value) = change_receiver.next().await {
                    *current_value.lock().await = value;
                    notifier.lock().await.notify(value.into()).await;
                }
            },
            abort_registration,
        )
        .unwrap_or_else(|_| ()),
    )
    .detach();

    abort_handle
}
/// Sends out a notificaiton when value changes. Abortable to allow for
/// startListen and endListen.
Sends out a notificaiton when value changes. Abortable to allow for
startListen and endListen.
Sends out a notificaiton when value changes . Abortable to allow for startListen and endListen .
async fn notify_on_change(
    mut change_receiver: UnboundedReceiver<LightData>,
    notifier: Arc<Mutex<dyn LightNotifier + Send + Sync>>,
    current_value: Arc<Mutex<LightData>>,
) -> AbortHandle {
    let (abort_handle, abort_registration) = AbortHandle::new_pair();
    fasync::Task::spawn(
        Abortable::new(
            async move {
                while let Some(value) = change_receiver.next().await {
                    *current_value.lock().await = value;
                    notifier.lock().await.notify(value.into()).await;
                }
            },
            abort_registration,
        )
        .unwrap_or_else(|_| ()),
    )
    .detach();
    abort_handle
}
async fn notify_on_change ( mut change_receiver : UnboundedReceiver < LightData > , notifier : Arc < Mutex < dyn LightNotifier + Send + Sync > > , current_value : Arc < Mutex < LightData > > , ) -> AbortHandle { let ( abort_handle , abort_registration ) = AbortHandle :: new_pair ( ) ; fasync :: Task :: spawn ( Abortable :: new ( async move { while let Some ( value ) = change_receiver . next ( ) . await { * current_value . lock ( ) . await = value ; notifier . lock ( ) . await . notify ( value . into ( ) ) . await ; } } , abort_registration , ) . unwrap_or_else ( | _ | ( ) ) , ) . detach ( ) ; abort_handle }
Sends out a notificaiton when value changes.
Sends out a notificaiton when value changes .
change_receiver
UnboundedReceiver<LightData>
notifier
Arc<Mutex<dyn LightNotifier + Send + Sync>>
current_value
Arc<Mutex<LightData>>
change_receiver
UnboundedReceiver<LightData>
notifier
Arc<Mutex<dyn LightNotifier + Send + Sync>>
current_value
Arc<Mutex<LightData>>