SwiftFlux
SwiftFlux copied to clipboard
[Proposal]Error handling by ErrorAction instead of antitypical/Result
Many Action is always success.
I think antitypical/Result
is overkill for represent Action's error.
before
struct SampleAction: Action {
func invoke(dispatcher: DIspatcher) {
someFunc() { (result, error) in
if error {
dispatcher.dispatch(self, Result(error: error))
} else {
dispatcher.dispatch(self, Result(value: result))
}
}
}
}
My plan is
struct SampleAction: Action {
func invoke(dispatcher: DIspatcher) {
someFunc() { (result, error) in
if error {
ActionCreator.invoke(SomeErrorAction(error: error))
} else {
dispatcher.dispatch(self, result)
}
}
}
}
I think this will make the SampleAction
ambiguous about what Action
it will dispatch in the end.
And thats why we suggesting separate the role of definition of a Action
and the creation of a Action
into separate classes in #15.