Closed LRNZ09 closed 4 years ago
I'm pretty sure this would be a potential solution for #11 as well (assuming the issue reporter there is okay with using classes).
Ah, yes you're right. This used to be supported out of the box in Dart 1 (callable classes would actually pass the is
check without needing to verify action.call
), but I forgot to support this for Dart 2. I'll add it in :)
I'm curious to see your solution. I wasn't able to figure out if a object is callable or not without resorting to mirrors. Using action.call is ThunkAction<State>
fails when an action that doesn't define a call
function hits the middleware. I ended up using an abstract class and making my callable actions extend it.
This would be really useful when you need a payload within your ThunkAction.
For example this function:
It needs
url
as a param, and could have even some more.How it could be:
The middleware should check the action like this: