when<T extends Object> method
T
when<T extends Object>({
- required T loading(
- LceLoading<
DATA> state
- LceLoading<
- required T content(
- LceContent<
DATA> state
- LceContent<
- required T error(
- LceError<
DATA> state
- LceError<
- T terminated()?,
override
Emulates sealed class with every state callback required except
terminated
. Override it if you expect termination or leave empty
to throw exception
Implementation
@override
T when<T extends Object>({
required T Function(LceLoading<DATA> state) loading,
required T Function(LceContent<DATA> state) content,
required T Function(LceError<DATA> state) error,
T Function()? terminated
}) {
if (null == terminated) {
throw UnimplementedError('Unexpected termination. Terminated handler not implemented');
};
return terminated();
}