Skip to content

Instantly share code, notes, and snippets.

@AlexVegner
Last active January 19, 2020 05:06
Show Gist options
  • Save AlexVegner/e08c5154c69ecfba333a8132716716af to your computer and use it in GitHub Desktop.
Save AlexVegner/e08c5154c69ecfba333a8132716716af to your computer and use it in GitHub Desktop.
Smart Event for bloc
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