enonic / doc-xp

Enonic XP > 7.0 Reference Documentation
2 stars 3 forks source link

Document Event Listener Event Type Pattern #153

Open ComLock opened 4 years ago

ComLock commented 4 years ago

ref: https://developer.enonic.com/docs/xp/stable/api/lib-event#listener

It's not RegExp, but similar

WRONG '(node.(created|updated|deleted)|task..*)'

RIGHT '(node.(created|updated|deleted)|task.*)'

So a dot, simply means a dot, not any char like in regexp. And a asterix means wildcard. Uncertain wether it means anything, 0 or more times.

rymsha commented 4 years ago

According to the code intention was to support some sort of glob syntax or even less. . - means only dot * - matches any number of any characters including none

so prefix.* matches anything that starts with prefix. and first.second matches only first.second and nothing more

Everything else that "works" now but should not - I would consider a bug.

ComLock commented 4 years ago

So the parentheses and pipe char to signify groups and alternatives should not work then? Seems more like a nice magic feature to me :)

rymsha commented 4 years ago

Indeed. Magic. For your use-case create two listeners: node.* and task.* In case you are not interested in node.push, filter it out in listener itself.

If you really want magic, subscribe to * and do a filtering in js code. It may be even more optimal for overall system throughput.

ComLock commented 4 years ago

Well that's good to know. My assumption was that the API would be more optimised than each developers own code.