Problem with Signal AddOnce

21 views
Skip to first unread message

krishna...@juegostudio.net

unread,
Jun 14, 2018, 6:09:56 AM6/14/18
to StrangeIoC
Hello, I have two commands and i am inejcting my service into those commands.  I have a two signals in service(Successignal & failuresignal). in each command i have added signal listeners with AddOnce. after getting response from server, I am dispatching siganls ... after once command release, listeners on working.. then for second command listerner methods also attached inside addonce method. but when dispatch the signal oncelisteners shows null... it is not going to my second command listeners.. What is the problm?????

wcorwin

unread,
Jun 18, 2018, 10:03:00 PM6/18/18
to StrangeIoC
Let me see if I understand you correctly.

- You have two signals, SuccessSignal and FailureSignal. These are bound directly to the injectionBinder. They are injected in to a Service
- You have two commands. They are completely separate classes, which only extend Command. They are not sequenced, and they are not bound using a SignalCommandBinder to the SuccessSignal or FailureSignal. Some other means is used to execute these commands. This Service is injected in to each of these two commands.
- In each command's execute method, you are calling AddOnce(myMethod) on both SuccessSignal and FailureSignal. You are at some point calling Retain() on the Command.
- Something happens in your service externally, and you receive a response.
- You now dispatch either the SuccessSignal or the FailureSignal. The method your first Command added as a listener now executes.
- The second command's listener for that signal does not execute.

If I have that correct, here are a few ideas to look in to:

Make sure...
- You are executing and adding a listener in both commands, and before the signal dispatches. Race conditions can exist for these situations very easily. I would advise using a Promise, if it helps.
- You are calling Retain() in both commands. (Technically unnecessary but very useful for cleaning up, especially if you're adding listeners in this manner which won't clean up automatically!)
- You are not clearing those signals anywhere else in the code or removing listeners. That's doubly true if you're manually editing delegates.


It's possible I've gotten a step wrong, so I'll leave it at that. Let me know if this helps!


Reply all
Reply to author
Forward
0 new messages