maybeMap<R> method
R
maybeMap<R>({
- required R orElse(),
- R ready(
- ResourceReady<
T> ready
- ResourceReady<
- R error(
- ResourceError<
T> error
- ResourceError<
- R loading(
- ResourceLoading<
T> loading
- ResourceLoading<
Perform some actions based on the state of the ResourceState, or call orElse if the current state is not considered.
Implementation
R maybeMap<R>({
required R Function() orElse,
R Function(ResourceReady<T> ready)? ready,
R Function(ResourceError<T> error)? error,
R Function(ResourceLoading<T> loading)? loading,
}) {
return map(
ready: (r) {
if (ready != null) return ready(r);
return orElse();
},
error: (d) {
if (error != null) return error(d);
return orElse();
},
loading: (l) {
if (loading != null) return loading(l);
return orElse();
},
);
}