easy-peasy
easy-peasy copied to clipboard
thunk completeType not called on fail
It appears that a failed thunk does not trigger the complete action type.
So a saveTodo
thunk should always trigger listeners for saveTodo.type
, which it does so for a successful thunk, but not a failed thunk.
Full response in the works. :)
With v4+, to trigger the fail
action on a failed thunk, you need to call the fail()
function, which is passed on the helpers object but was not mentioned in the docs. I have opened two PRs to both add it to the Helpers Typescript type definition as well as document its usage in the api/thunks docs:
#572 #574
@ctrlplusb hope this is helpful! =)
Yes I know, but the type
action still doesn't get called either way. Which it always should, no matter if it succeeded or failed, as it still completed.
Apologies, I'm afraid I misread your initial statement. Sean clearly understands, but it might benefit others to have a little more information. Looking from the docs inward, I'm unaware of a type
action existing or being expected.
When I say the type
action, I mean the default action. Take a look at https://easy-peasy.now.sh/docs/api/listeners.html#thunkon
...actions => actions.addTodo
Then with thunks, you also have the start, success and fail actions:
...actions => actions.saveTodo.successType