Skip to content

Commit

Permalink
feat: getItLoginBloc 삭제
Browse files Browse the repository at this point in the history
1. LoginBloc의 경우 싱글톤이 아닌 팩토리로 등록하기 때문에 getIt으로 조회하면 각각의 인스턴스로 취급되는 것 같음
  • Loading branch information
Younggun-Kim committed Nov 9, 2024
1 parent 37124f0 commit f739c80
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
2 changes: 0 additions & 2 deletions lib/feature/account/init_injections.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import 'package:withu_app/core/core.dart';
import 'package:withu_app/feature/account/account.dart';

LoginBloc get getItLoginBloc => getIt<LoginBloc>();

void initAccountInjections() {
getIt.registerSingleton<AccountApi>(
Environment.isProd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ extension LoginBlocHandler on LoginBloc {
LoginMessageCleared event,
Emitter<LoginState> emit,
) {
emit(state.copyWith(message: ''));
emit(state.copyWith(
status: BaseBlocStatus.initial(),
message: '',
));
}

/// 아이디 입력
Expand Down
20 changes: 9 additions & 11 deletions lib/feature/account/presentation/page/login/login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,21 @@ class _LoginPageState extends State<LoginPageContent> {
@override
Widget build(BuildContext context) {
return BlocConsumer<LoginBloc, LoginState>(
listener: (context, state) {
listener: (context, state) async {
/// 로그인 성공
if (state.status.isSuccess) {
getItAppRouter.replaceAll([const JobPostingsRoute()]);
}

/// 로그인 실패
if (state.status.isFailure) {
if (state.message.isNotEmpty) {
CustomAlertDialog.showContentAlert(
context: context,
content: state.message,
closeCallback: () {
getItLoginBloc.add(LoginMessageCleared());
},
);
}
if (state.status.isFailure && state.message.isNotEmpty) {
await CustomAlertDialog.showContentAlert(
context: context,
content: state.message,
closeCallback: () {
context.read<LoginBloc>().add(LoginMessageCleared());
},
);
}
},
builder: (context, state) {
Expand Down

0 comments on commit f739c80

Please sign in to comment.