make-event-bus returns a closure, which can receive a set of messages.
The bus mentioned here is a scheme object, which was created by the make-event-bus
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.
(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.
(bus 'receivers 'symbol) ; => (#<procedure some-other-receiver> #<procedure some-receiver>)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 happen
(bus 'receivers 'symbol) ; => ()Resets 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 'receivers) ; => #((another-symbol #<procedure some-receiver>) (symbol #<procedure some-receiver>))
(bus 'reset!)
(bus 'receivers) ; => #()Returns a vector, which consists of all the event receivers. If an event is provided, it narrows the scope to the list of receivers of a given event. Any returned value is a copy.
(define (some-receiver symbol)
(format #t "Got a symbol: ~A~%" symbol))
(bus 'attach! 'symbol some-receiver)
(bus 'attach! 'another-symbol some-receiver)
(bus 'receivers) ; => #((another-symbol #<procedure some-receiver>) (symbol #<procedure some-receiver>))
(bus 'receivers 'symbol) ; => (#<procedure some-receiver>)