mirror of
https://github.com/h7x4/Jisho-Study-Tool.git
synced 2024-12-21 13:37:29 +01:00
Add event for returning to initial state
This commit is contained in:
parent
8ee5dc7f58
commit
d126f54500
@ -17,14 +17,19 @@ class KanjiBloc extends Bloc<KanjiEvent, KanjiState> {
|
||||
Stream<KanjiState> mapEventToState(
|
||||
KanjiEvent event,
|
||||
) async* {
|
||||
yield KanjiSearchLoading();
|
||||
if (event is GetKanji) {
|
||||
|
||||
yield KanjiSearchLoading();
|
||||
|
||||
try {
|
||||
final _kanji = await fetchKanji(event.kanjiSearchString);
|
||||
yield KanjiSearchFinished(_kanji);
|
||||
} on Exception {
|
||||
yield KanjiSearchError('Something went wrong');
|
||||
}
|
||||
|
||||
} else if (event is ReturnToInitialState) {
|
||||
yield KanjiSearchInitial();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,4 +6,8 @@ class GetKanji extends KanjiEvent {
|
||||
final String kanjiSearchString;
|
||||
|
||||
GetKanji(this.kanjiSearchString);
|
||||
}
|
||||
|
||||
class ReturnToInitialState extends KanjiEvent {
|
||||
ReturnToInitialState();
|
||||
}
|
Loading…
Reference in New Issue
Block a user