Skip to content

Commit

Permalink
refactor : viewModel 함수 init 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
huiwoo-jo committed Mar 28, 2024
1 parent b5b3e2d commit dc52fba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ class DepartActivity : BaseActivity<ActivityDepartBinding, DepartViewModel>(), D
}

override fun initAfterBinding() {
viewModel.getUserDepartment()

viewModel.selectDepartPosition.observe(this) {
adapter.submitPosition(it)
if (it != -1) getDepart(items)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ class DepartViewModel(private val departRepository: DepartRepository) : BaseView
private val _selectDepartPosition = MutableLiveData(-1)
val selectDepartPosition: LiveData<Int> get() = _selectDepartPosition

init {
getUserDepartment()
}

fun getUserDepartment() {
val myDepartment = departRepository.getUserDepartment()
_myDepartment.postValue(myDepartment)
Expand Down

0 comments on commit dc52fba

Please sign in to comment.