50Ply Blog

Building Things

Lexicographical Events

| Comments

I made up that name but here’s the big idea:

Define an event to be an ordered list where the each entry in the list provides more specific information about the nature of the event. For example:

1
[ :click,  :button,  widget-ref ]

When the event is fired, build the set of sublists built by extending the empty list by one element and fire those instead. So, firing the event above would fire these events:

1
2
3
4
[]
[:click]
[:click, :button]
[:click, :button, widget-ref]

Then, if you want to know if a specific widget is clicked, you can listen for the [:click, :button, widget-ref] event. If you want to know about all clicks you can register for [:click]. If you want a view into every single event fired then register for [].

Here’s an implementation of the idea in Clojurescript.

Comments