1
0
Fork 0

Prevent iced subscriptions from spinning

This commit is contained in:
Robbert van der Helm 2022-03-15 15:52:29 +01:00
parent 01e7998c03
commit 1ead41050c

View file

@ -5,6 +5,7 @@ use crossbeam::channel;
use nih_plug::prelude::GuiContext; use nih_plug::prelude::GuiContext;
use std::sync::Arc; use std::sync::Arc;
use crate::futures::FutureExt;
use crate::{ use crate::{
futures, subscription, Application, Color, Command, Element, IcedEditor, Subscription, futures, subscription, Application, Color, Command, Element, IcedEditor, Subscription,
WindowQueue, WindowScalePolicy, WindowSubs, WindowQueue, WindowScalePolicy, WindowSubs,
@ -111,14 +112,13 @@ impl<E: IcedEditor> Application for IcedEditorWrapperApplication<E> {
subscription::unfold( subscription::unfold(
"parameter updates", "parameter updates",
self.parameter_updates_receiver.clone(), self.parameter_updates_receiver.clone(),
|parameter_updates_receiver| { |parameter_updates_receiver| match parameter_updates_receiver.try_recv() {
futures::future::ready(( Ok(_) => futures::future::ready((
parameter_updates_receiver Some(Message::ParameterUpdate),
.try_recv()
.ok()
.map(|_| Message::ParameterUpdate),
parameter_updates_receiver, parameter_updates_receiver,
)) ))
.boxed(),
Err(_) => futures::future::pending().boxed(),
}, },
), ),
self.editor self.editor