From da5452f90f86bf1c1fdacccc2b2152ac7d64cb02 Mon Sep 17 00:00:00 2001 From: Gregor Reitzenstein Date: Tue, 15 Sep 2020 17:04:13 +0200 Subject: [PATCH] Signal deduping --- src/machine.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/machine.rs b/src/machine.rs index 792a874..d7fb90e 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -120,8 +120,16 @@ impl Machine { } } - pub fn signal(&self) -> MutableSignal { - self.state.signal() + /// Generate a signal from the internal state. + /// + /// A signal is a lossy stream of state changes. Lossy in that if changes happen in quick + /// succession intermediary values may be lost. But this isn't really relevant in this case + /// since the only relevant state is the latest one. + /// dedupe ensures that if state is changed but only changes to the value it had beforehand + /// (could for example happen if the machine changes current user but stays activated) no + /// update is sent. + pub fn signal(&self) -> impl Signal { + self.state.signal().dedupe() } }