LogIn Redux Cycle
Let's wire up a button in our app that logs in a user with Firebase.
auth_actions
file.
1. Add a new 2. Add relevant actions:
// actions/auth_actions.dart
import 'package:firebase_auth/firebase_auth.dart';
// gives us access to `@required`
import 'package:flutter/foundation.dart';
class LogIn {}
class LogInSuccessful {
final FirebaseUser user;
LogInSuccessful({ this.user});
String toString() {
return 'LogIn{user: $user}';
}
}
class LogInFail {
final dynamic error;
LogInFail(this.error);
String toString() {
return 'LogIn{There was an error loggin in: $error}';
}
}
class LogOut {}
class LogOutSuccessful {
LogOutSuccessful();
String toString() {
return 'LogOut{user: null}';
}
}
These are our basic actions. From here, we need to write our first middleware. That takes a bit of an aside, and then we'll return to our Redux cycle.