make-event-bus returns a closure, which can receive a set of messages.
Provide #t if you want your event-bus throwing error when same procedure is added multiple times to the same event (#f to disable)
The bus mentioned here is a scheme object, which was created by the make-event-bus
Runs all events
Calls all of the event receivers, with given set of arguments.
(bus 'propagate! 'event 'next-come-the-arguments)Checks if the receiver has been attached to the event.
Attaches a receiver function to the event. You cannot duplicate receivers.
If #t was provided to make-event-bus, additional check will be executed to ensure that the procedure is unique for that event
(define (some-receiver symbol)
(format #t "Got a symbol: ~A~%" symbol))
(define (some-other-receiver symbol)
(format #t "Hey, thats a symbol: ~A~%" symbol))
(bus 'attach! 'symbol some-receiver)
(bus 'attach! 'symbol some-other-receiver)
(bus 'propagate! 'symbol 'foo) ; Those two functions get called.Detaches a receiver function from an event.
(define (some-receiver symbol)
(format #t "Got a symbol: ~A~%" symbol))
(bus 'attach! 'symbol some-receiver)
(bus 'detach! 'symbol some-receiver)
(bus 'propagate! 'symbol 'foo) ; Nothing will happenResets a bus to an initial state.
(define (some-receiver symbol)
(format #t "Got a symbol: ~A~%" symbol))
(bus 'attach! 'symbol some-receiver)
(bus 'attach! 'another-symbol some-receiver)
(bus 'reset!) ; => bus is emptyDumps the internal bus hashtable
(hashtable-values (bus 'dump-bus))
;; => #(((#{ebus-procedure-token: fx3240cs5gwemy2596v1k6lcv-5}
;; .
;; #<procedure>)))