Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some help needed with understanding #25

Closed
joshhornby opened this issue Nov 9, 2014 · 2 comments
Closed

Some help needed with understanding #25

joshhornby opened this issue Nov 9, 2014 · 2 comments

Comments

@joshhornby
Copy link

Hey,

I love the idea of the package but the documentation isn't very clear and I have spotted a few mistakes. Is the repo on Github?

Anyway I am having some difficulty understanding how to set the listeners up correctly, so far I have this:

$emitter = new Emitter();

$emitter->addListener('NewIssueEvent', function ($event) {
    echo $event->getName(); 
});

$emitter->emit(new NewIssueEvent);

Now what is the correct way to call my listener? is it as simple as newing one up? new NewIssueEventListener(); But this doesn't seem correct as then what is the point in the handle function?

I'd love a quick example set up of class based events and listeners. Thanks 👍

@frankdejonge
Copy link
Member

@joshhornby Hi Josh, sorry for the late reply. I had already fixed this problem by working on the documentation but forgot to respond to this issue. The class based listener is places where the closure is places. So:

$emitter->addListener('NewIssueEvent', new NewIssueListener);

Does that answer your question?

PS: I've updated the documentation, which is located on the gh-pages branch.

@frankdejonge
Copy link
Member

An addListener example is added to this page: http://event.thephpleague.com/1.0/listeners/class-based-listeners/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants