Davide Giuseppe Farella
03/23/2019, 4:59 PMtypealias on a lambda:
typealias ErrorStateGenerator = ErrorStateFactory.(Throwable) -> ViewState.Error
ErrorStateFactory provides a default val.
This is a typical use case:
ViewStateStoreConfig.errorStateGenerator = {
when( it ) {
is NullPointerException -> NPError( it )
is IllegalArgumentException -> IAError( it )
else -> default
}
}
I was wondering a common scenario where the user only got some dependencies ( exceptions ) in certain modules, so this would be helpful:
ViewStateStoreConfig.errorStateGenerator =
generatorFromThisModule + generatorFromModule2 + generatorFromModule3
So I would need a class for wraps the `ErrorStateGenerator`s; this class should extend ErrorStateGenerator itself, but is not possible since ErrorStateGenerator is an extension function…
Which solution would you suggest?