toResource

Map a NetworkEither to ResourceEither with the network Failure and Success as lambda params

networkEither.toResource(
left = { failure: Failure<SomeFailure> ->
buildResource(failure)
},
right = { success: Success<SomeSuccess> ->
buildResource(failure)
},
)

inline fun <NF, NS, F, S> NetworkEither<NF, NS>.toResource(httpError: (NetworkEither.Failure.Http<NF>) -> F, localError: () -> F, remoteError: () -> F, unknownError: (Throwable) -> F, success: (NetworkEither.Success<NS>) -> S, isLoading: Boolean = false): ResourceEither<F, S>

Map a NetworkEither to ResourceEither with network Failure and Success unwrapped as lambda params

networkEither.toResource(
success = { data: Data, code: Int, headers: Headers ->
buildResource(data, code, headers)
},
httpError = { error: Error, code: Int, headers: Headers ->
buildResource(error, code, headers)
},
localError = { buildResource() },
remoteError = { buildResource() }
unknownError = { unknownError: Throwable -> buildResource(unknownError) }
)