summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--2d/signals.scm14
1 files changed, 13 insertions, 1 deletions
diff --git a/2d/signals.scm b/2d/signals.scm
index 04de9c0..85cc5af 100644
--- a/2d/signals.scm
+++ b/2d/signals.scm
@@ -51,7 +51,8 @@
signal-and
signal-or
signal-when
- signal-unless))
+ signal-unless
+ signal-do))
;;;
;;; Signals
@@ -281,3 +282,14 @@ is never true."
#:transformer (lambda (value prev from)
(signal-ref consequent))
#:connectors (list predicate consequent)))
+
+(define (signal-do proc signal)
+ "Create a new signal that applies PROC with incoming values from
+SIGNAL. The value of the new signal will always be the value of
+SIGNAL. This signal is a convenient way to apply a side-effect to a
+signal value."
+ (make-signal
+ #:transformer (lambda (value prev from)
+ (proc value)
+ value)
+ #:connectors (list signal)))