(in-package :org.unknownlamer.notifications.notifications) ;;; Event Metaclass (defclass standard-event-class (standard-class) ((observers :documentation "Collection of closures to notify when event is triggered")) (:documentation "Event metaclass")) ;; Protocol (defgeneric register-observer (event-type closure) (:documentation "Register a closure to be run when an event of type `event-type' is triggered. `closure' must take a single argument which is the actual event object")) (defgeneric unregister-observer (event-type closure) (:documentation "Cease to run `closure' when `event-type' is triggered. The first object that is eq `closure' will be removed.")) ;;; Event Class (defclass event () () (:documentation "Superclass for all events")) ;; Protocol (defgeneric trigger-event (event-type &key &allow-other-keys &rest initargs) (:documentation "Triggers an event of type `event-type' and passes all keyword arguments to make-instance"))