effector/effector

Throw in reducer is not cancel computation of other reducers

artalar opened this issue · 6 comments

If someone forwarded you here, this is an outdated discussion which can not and must not be used as proof of the issues of any kind.

Calling of pure function cannot be detected by definition, thereby preventing from using them in a suggested way
That is, the inability to throw an exception is what make functions pure.
And that is what effects were being made for: effect is a function, which might throw an exception, which triggers a fail branch, which you can subscribe on.

Reducers in .on, functions in .map are pure. You shall not branch them by throwing exceptions. This is not an issue, this is what makes computations predictable and stable.

Original issue:

Code to reproduce the issue:
repl

Expected behavior:
Throw all computation

Actual behavior:
Receive wrong data

Versions of packages used:
0.18.16

workaround (on russian)

костыльное решение: тригер процесса (addToCard) генерирует уникальный ID, который выражает последний успешный процесс вычислений. В price (в его комбайне), мы собираем все ID со всех зависимых сторов и проверяем что они одинаковые - значит апдейт был у всех и данные релевантные - можно обновляться (возвращать новый price)

related issue #51

Throwing errors is the completely wrong way to organize business logic, you don't need it at all because of filters, created especially for such cases. It more readable and significantly less error-prone than dealing with throw on a daily basis https://share.effector.dev/0zxWY3px

@zerobias
The predicate for the throw is not validation (from business logic) - it is just an example to testify a problem

Solution testified as well. You are trying to blame for the lack of support of double binding which latest significant appearance was in AngularJS more than five years ago