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

Listeners added while dispatching are dispatched. #21

Open
IkonOne opened this issue Mar 26, 2017 · 0 comments
Open

Listeners added while dispatching are dispatched. #21

IkonOne opened this issue Mar 26, 2017 · 0 comments

Comments

@IkonOne
Copy link

IkonOne commented Mar 26, 2017

My use case:

I have a Pointer class with a Signal, down. When the pointer is clicked down, the down signal dispatches. In this case I am creating a new Scene in the game that is registering new slots with the down signal. These new slots are fired immediately. That is no good for me because the Scene is brand new and the player clicked the mouse before the scene was created. Ideally, the signals would not dispatch to the new slots/listeners.

In writing this, I have figured out a workaround that will work in this case, but I would prefer signals to simply not dispatch immediately as this is unlikely to be the only instance that this occurs.

My thoughts on how to solve this are:

  1. Add a _dispatching variable and set it to true while dispatching...
  2. When listeners are added while dispatching, store them in a temporary list
  3. When finished dispatching, then add them to the slot list

EventSignals don't work in my case either as I am piggybacking off of two separate event systems (pixijs and openfl) which already handle everything I need. I am simply unifying the interfaces.

@IkonOne IkonOne changed the title Signals added while dispatching are dispatched. Listeners added while dispatching are dispatched. Mar 26, 2017
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

1 participant