diff options
Diffstat (limited to '2d/signals.scm')
-rw-r--r-- | 2d/signals.scm | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/2d/signals.scm b/2d/signals.scm index 4a455c2..28d2c6f 100644 --- a/2d/signals.scm +++ b/2d/signals.scm @@ -29,6 +29,7 @@ signal? make-signal signal-ref + signal-ref-maybe signal-transformer signal-listeners signal-connect! @@ -66,12 +67,19 @@ (init #f) (connectors '())) "Create a new signal with initial value INIT that uses the given TRANSFORMER procedure to process incoming values from another -signal. Additionally, the signal will be connected to all of the +signal. Additionally, the signal will be connected to all of the signals in the list CONNECTORS." (let ((signal (%make-signal init transformer '()))) (for-each (cut signal-connect! <> signal) connectors) signal)) +(define (signal-ref-maybe object) + "Dereferences OBJECT if it is a signal and returns OBJECT +otherwise." + (if (signal? object) + (signal-ref object) + object)) + (define (%signal-transform signal value from) "Call the transform procedure for SIGNAL with VALUE." ((signal-transformer signal) value (signal-ref signal) from)) |