Skip to content

How to subscribe to events emitted from a plugin? #1890

Answered by guest20
michaelfung asked this question in Q&A
Discussion options

You must be logged in to vote

You want the plugin to register a helper that makes $self available. If it's not your plugin you can just sub-class it and add the helper yourself.

# inside a plugin module:
sub register ($self, $app, $conf) {
  ...
   $app->helper(pluginName => sub { $self }); 
#elsewhere: 
$c->pluginName->on(...)

... it might be a bit late if the plugin emits an event during register though

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@michaelfung
Comment options

Answer selected by michaelfung
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants