parent
2f6b322136
commit
52dcc87b1c
@ -1,29 +1,25 @@ |
|||||||
import 'package:redux/redux.dart'; |
import 'package:redux/redux.dart'; |
||||||
import 'package:thesis_shop/models/product.dart'; |
|
||||||
import 'package:thesis_shop/models/remote_resource.dart'; |
import 'package:thesis_shop/models/remote_resource.dart'; |
||||||
|
|
||||||
import '../actions/actions.dart'; |
import '../actions/actions.dart'; |
||||||
|
import '../state.dart'; |
||||||
|
|
||||||
final productReducer = combineReducers([ |
final productReducer = combineReducers<RemoteProducts>([ |
||||||
TypedReducer<RemoteResource<List<Product>>, FetchProductsAction>( |
TypedReducer<RemoteProducts, FetchProductsAction>(fetchProducts), |
||||||
fetchProducts), |
TypedReducer<RemoteProducts, FetchProductsSucceededAction>(productFetched), |
||||||
TypedReducer<RemoteResource<List<Product>>, FetchProductsSucceededAction>( |
TypedReducer<RemoteProducts, FetchProductsFailedAction>(errorOccurred), |
||||||
productFetched), |
|
||||||
TypedReducer<RemoteResource<List<Product>>, FetchProductsFailedAction>( |
|
||||||
errorOccurred), |
|
||||||
]); |
]); |
||||||
|
|
||||||
RemoteResource<List<Product>> fetchProducts( |
RemoteProducts fetchProducts( |
||||||
RemoteResource<List<Product>> state, |
RemoteProducts state, |
||||||
FetchProductsAction action, |
FetchProductsAction action, |
||||||
) => |
) => |
||||||
const RemoteResource.loading(); |
const RemoteResource.loading(); |
||||||
|
|
||||||
RemoteResource<List<Product>> productFetched( |
RemoteProducts productFetched( |
||||||
RemoteResource<List<Product>> state, |
RemoteProducts state, FetchProductsSucceededAction action) => |
||||||
FetchProductsSucceededAction action) => |
|
||||||
RemoteResource.finished(action.products); |
RemoteResource.finished(action.products); |
||||||
|
|
||||||
RemoteResource<List<Product>> errorOccurred(RemoteResource<List<Product>> state, |
RemoteProducts errorOccurred( |
||||||
FetchProductsFailedAction action) => |
RemoteProducts state, FetchProductsFailedAction action) => |
||||||
RemoteResource.error(action.errorMessage); |
RemoteResource.error(action.errorMessage); |
||||||
|
Loading…
Reference in new issue