createDataSourceReducer

inline fun <Request, Response, State> createDataSourceReducer(key: PureDataSourceKey<DataSource<Request, Response>>, crossinline onStart: PayloadReducer<State, DataSourcePayload.Started<Request, Response>> = { s, _ -> s }, crossinline onSuccess: PayloadReducer<State, DataSourcePayload.Success<Request, Response>> = { s, _ -> s }, crossinline onFailure: PayloadReducer<State, DataSourcePayload.Failure<Request, Response>> = { s, _ -> s }, crossinline onElse: Reducer<State> = { s, _ -> s }): Reducer<State>

Creates a Reducer that:

By default, all branches return state unchanged.

Example of usage:

val reducer: Reducer<AppState> = createDataSourceReducer(
key = FooDataSource,
onStart = { state, (request) -> TODO("Create new state here") },
onSuccess = { state, (request, response) -> TODO("Create new state here") },
onFailure = { state, (request, error) -> TODO("Create new state here") },
onElse = { state, action -> TODO("Create new state here") },
)

inline fun <Request, Response, State> createDataSourceReducer(key: PureDataSourceKey<DataSource<Request, Response>>, crossinline onStart: PayloadReducer<State, DataSourcePayload.Started<Request, Response>> = { s, _ -> s }, noinline onResult: PayloadReducer<State, DataSourceResultPayload<Request, Response>> = { s, _ -> s }, crossinline onElse: Reducer<State> = { s, _ -> s }): Reducer<State>

Creates a Reducer that:

Example of usage:

val reducer: Reducer<AppState> = createDataSourceReducer(
key = FooDataSource,
onStart = { state, (request) -> TODO("Create new state here") },
onResult = { state, (request, result) -> TODO("Create new state here") },
onElse = { state, action -> TODO("Create new state here") },
)