when<T extends Object> method

  1. @override
T when<T extends Object>({
  1. required T loading(
    1. LceLoading<DATA> state
    ),
  2. required T content(
    1. LceContent<DATA> state
    ),
  3. required T error(
    1. LceError<DATA> state
    ),
  4. 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();
}