mirror of
https://github.com/h7x4/Jisho-Study-Tool.git
synced 2024-12-22 22:07:29 +01:00
25 lines
579 B
Dart
25 lines
579 B
Dart
|
|
||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||
|
|
||
|
import './database_event.dart';
|
||
|
import './database_state.dart';
|
||
|
|
||
|
export './database_event.dart';
|
||
|
export './database_state.dart';
|
||
|
export './database_not_connected_exception.dart';
|
||
|
|
||
|
class DatabaseBloc extends Bloc<DatabaseEvent, DatabaseState> {
|
||
|
|
||
|
DatabaseBloc() : super(DatabaseDisconnected());
|
||
|
|
||
|
@override
|
||
|
Stream<DatabaseState> mapEventToState(DatabaseEvent event)
|
||
|
async* {
|
||
|
if (event is ConnectedToDatabase) {
|
||
|
yield DatabaseConnected(event.database);
|
||
|
} else {
|
||
|
yield DatabaseDisconnected();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|