Fixed onError event dispatching#80
Conversation
There was a problem hiding this comment.
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.
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
|
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.