diff --git a/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeFragment.kt b/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeFragment.kt index 13bbf52c..e512d25e 100644 --- a/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeFragment.kt +++ b/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeFragment.kt @@ -7,19 +7,26 @@ import android.view.ViewGroup import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels import com.android.mediproject.core.ui.base.BaseFragment +import com.wap.wapp.core.base.util.repeatOnStarted import com.wap.wapp.feature.notice.databinding.FragmentNoticeBinding import dagger.hilt.android.AndroidEntryPoint @AndroidEntryPoint class NoticeFragment : - BaseFragment(FragmentNoticeBinding::inflate) { + BaseFragment(FragmentNoticeBinding::inflate) { override val fragmentViewModel: NoticeViewModel by viewModels() override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - binding.apply{ - viewModel = fragmentViewModel.apply{ - + binding.apply { + viewModel = fragmentViewModel.apply { + repeatOnStarted { eventFlow.collect { handleEvent(it) } } } } } + + private fun handleEvent(event : NoticeViewModel.NoticeEvent){ + when(event){ + else -> {} + } + } } diff --git a/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt b/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt index 60d90ea8..43c36e04 100644 --- a/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt +++ b/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt @@ -1,9 +1,23 @@ package com.wap.wapp.feature.notice import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.flow.MutableSharedFlow +import kotlinx.coroutines.flow.asSharedFlow +import kotlinx.coroutines.launch import javax.inject.Inject @HiltViewModel class NoticeViewModel @Inject constructor() : ViewModel() { + private val _eventFlow = MutableSharedFlow() + val eventFlow = _eventFlow.asSharedFlow() + + private fun event(event: NoticeEvent) = viewModelScope.launch { + _eventFlow.emit(event) + } + + sealed class NoticeEvent { + + } }