diff --git a/src/output/blinking_led_task.rs b/src/output/blinking_led_task.rs index 2c2e5b2..351fe5a 100644 --- a/src/output/blinking_led_task.rs +++ b/src/output/blinking_led_task.rs @@ -24,11 +24,19 @@ pub fn blinking_led_task( } } +/// Spawn a task that periodically emits a blinking LED trigger. +/// +/// Needed to synchronize the frequencies of all blinking LEDs. +/// +/// Returns a subscriber for receiving update triggers. The initial +/// update is available immediately and emitted as a change notification. #[cfg(feature = "blinking-led-task-tokio-rt")] #[must_use] pub fn spawn_blinking_led_task(period: Duration) -> discro::Subscriber { let publisher = Publisher::new(BlinkingLedOutput::ON); - let subscriber = publisher.subscribe(); + // Mark the subscriber as changed on subscription for emitting + // an initial change notification immediately. + let subscriber = publisher.subscribe_changed(); let task = blinking_led_task(period, publisher); tokio::spawn(task); subscriber