-
-
Notifications
You must be signed in to change notification settings - Fork 151
Fixed onError event dispatching #80
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tady ten by tu být neměl aby se ověřilo že se to zavolá ikdyž je tam jenom jeden onSuccess
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ono se to nevolalo pokud error nastal v posledním onSuccess handleru - jejich celkový počet nemá vliv, tedy je jedno zda tenhle onSuccess odstraním či nikoli
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pravda :)
|
Should I refactor it to this? It has better performance because isValid is not called multiple times. (each isValid call means going through the whole component subtree) if (!$this->isValid()) {
$this->onError($this);
} elseif ($this->onSuccess) {
foreach ($this->onSuccess as $handler) {
$params = Nette\Utils\Callback::toReflection($handler)->getParameters();
$values = isset($params[1]) ? $this->getValues($params[1]->isArray()) : NULL;
Nette\Utils\Callback::invoke($handler, $this, $values);
if (!$this->isValid()) {
$this->onError($this);
break;
}
}
} |
|
Can you write better commit message? |
|
What's wrong with this one? I can't come up with anything better. |
|
|
|
@vojtech-dobes That's actually wrong. The onError event previously wasn't called if the error was added by last onSuccess handler (regardless how many there are in total). |
|
Maybe |
|
|
Commit message changed (thx @fprochazka). I've also changed the implementation to the one with better performance as mentioned above. |
|
👍 |
|
Thank you |
This closes #71.