Closed jordond closed 5 years ago
The default value for after
is definitely missing, but I think the (state: S, action: A?) -> Unit
signature is correct, since the provided action
is the result of applying all following interceptions. So it can be of any subtype of A
and is nullable.
The cast action as T
for after
seems to be the actual error. Classic copy-paste mistake… 😓
Ah, that was my first thought as well. But then I rationalized it as the dev might want to pipe after some other Action
(in the before
) was adapted to the target Action
.
Does that make sense? Hah in my head it does.
But I can definitely make the change if you want, as that was my original plan.
Oh, you're absolutely correct. 😅 With the if (target(action))
check it's already working like that… Guess I mixed that up as well. Then your change is completely valid. Although you can even make it a non-nullable type then. (Change it to T
instead of T?
.)
Thanks for the catch!
We are casting the action
action as T
, but the lambda signature was still set to the originalA
.I also added a default value for
after
. Which has the benefit of being able to usepipe(before={...})
without having to supply an after lambda as well. This of course also allows the developer to just dopipe()
, and nothing will happen...I have a proposal PR coming, that might help with that.