diff options
author | David Thompson <dthompson@member.fsf.org> | 2013-11-30 12:33:31 -0500 |
---|---|---|
committer | David Thompson <dthompson@member.fsf.org> | 2013-11-30 12:33:31 -0500 |
commit | 781a3dcacedc210e51e9dfc6669b4319a48878ab (patch) | |
tree | 2817a2f9bb10811a3f470c6b7cd74ca0e65d1d01 | |
parent | dec204b546e128dcf3eb7ad30a21e97ead1a69f1 (diff) |
Add signal-ref-maybe procedure.
* 2d/signals.scm (signal-ref-maybe): New procedure.
-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)) |