Skip to content

Instantly share code, notes, and snippets.

@jeantessier
Created January 19, 2017 07:29
Show Gist options
  • Save jeantessier/e6576ed8179a100f1a2b8ebbffda7c74 to your computer and use it in GitHub Desktop.
Save jeantessier/e6576ed8179a100f1a2b8ebbffda7c74 to your computer and use it in GitHub Desktop.
A listener class has a series of handlers, each with a `match` and a `handle` closure. Each closure has an optional `origin` parameter.
handlers.findAll { name, handler ->
if (handler.match.maximumNumberOfParameters == 1) {
handler.match notification
} else {
handler.match notification, origin
}
}.each { name, handler ->
if (handler.handle.maximumNumberOfParameters == 1) {
handler.handle notification
} else {
handler.handle notification, origin
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment