Last active
January 19, 2020 05:06
-
-
Save AlexVegner/e08c5154c69ecfba333a8132716716af to your computer and use it in GitHub Desktop.
Smart Event for bloc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class BaseEvent<State, Bloc> { | |
Stream<State> call(Bloc bloc); | |
} | |
class AuthBloc extends Bloc<AuthEvent, AuthState> { | |
@override | |
AccountsState get initialState => InitialAuthState(); | |
@override | |
Stream<AccountsState> mapEventToState(AuthEvent event) async* { | |
yield* event(this); | |
} | |
} | |
abstract AuthEvent { | |
} | |
class SetAuthEvent extends BaseBloc<AuthState, AuthBloc> { | |
@override | |
Stream<AuthState> call(AuthBloc bloc) async* { | |
yield InitialAuthState(afterInitial: true); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment