More redux work
This commit is contained in:
parent
7dddf03e32
commit
657fecdf17
9 changed files with 278 additions and 219 deletions
|
|
@ -1,5 +1,4 @@
|
|||
import 'actions.dart';
|
||||
import '../models/user.dart';
|
||||
import '../models/appState.dart';
|
||||
|
||||
AppState appReducer(AppState state, action) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,20 @@
|
|||
import '../models/fireMapState.dart';
|
||||
import 'package:redux/redux.dart';
|
||||
|
||||
FireMapState fireMapReducer(FireMapState state, action) {
|
||||
return state;
|
||||
}
|
||||
import '../models/fireMapState.dart';
|
||||
import 'actions.dart';
|
||||
|
||||
final fireMapReducer = combineReducers<FireMapState>([
|
||||
new TypedReducer<FireMapState, ShowYourLocationMapAction>(
|
||||
_showYourLocationMap),
|
||||
]);
|
||||
|
||||
FireMapState _showYourLocationMap(
|
||||
FireMapState state, ShowYourLocationMapAction action) {
|
||||
if (action.loc.subscribed) {
|
||||
return state.copyWith(
|
||||
status: action.loc.subscribed
|
||||
? FireMapStatus.unsubscribe
|
||||
: FireMapStatus.view,
|
||||
yourLocation: action.loc);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import 'package:bson_objectid/bson_objectid.dart';
|
|||
import 'package:fires_flutter/models/yourLocation.dart';
|
||||
|
||||
|
||||
|
||||
abstract class YourLocationActions {}
|
||||
|
||||
class AddYourLocationAction extends YourLocationActions {
|
||||
|
|
@ -17,6 +16,12 @@ class AddedYourLocationAction extends YourLocationActions {
|
|||
AddedYourLocationAction(this.loc);
|
||||
}
|
||||
|
||||
class ShowYourLocationMapAction extends YourLocationActions {
|
||||
YourLocation loc;
|
||||
|
||||
ShowYourLocationMapAction(this.loc);
|
||||
}
|
||||
|
||||
class DeleteYourLocationAction extends YourLocationActions {
|
||||
ObjectId id;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue