Skip to content

Wire BaseViewModel protocol into BaseViewController and migrate Account VM/VC to delegate-based error handling#2

Open
ibrahimethem wants to merge 4 commits into
masterfrom
codex/create-base-vc-and-vm-for-mvvm
Open

Wire BaseViewModel protocol into BaseViewController and migrate Account VM/VC to delegate-based error handling#2
ibrahimethem wants to merge 4 commits into
masterfrom
codex/create-base-vc-and-vm-for-mvvm

Conversation

@ibrahimethem
Copy link
Copy Markdown
Owner

Motivation

  • Standardize MVVM wiring and centralize error presentation by requiring a view model protocol and delegating error reporting through a base delegate interface.
  • Replace ad-hoc closures for error handling with a protocol/delegate approach so view controllers can receive errors via BaseViewModelDelegate.

Description

  • Add BaseViewModelDelegate and BaseViewModelProtocol and make BaseViewModel conform to BaseViewModelProtocol with a weak var delegate accessor in Topical Dictionary/ViewModel/BaseViewModel.swift.
  • Update BaseViewController to expose var baseViewModel: BaseViewModelProtocol? that assigns baseViewModel?.delegate = self and implement didReceiveError(_:) which calls presentError(_:) in Topical Dictionary/Controller/BaseViewController.swift.
  • Migrate AccountViewModel to inherit BaseViewModel, call delegate?.didReceiveError(err) on errors, and keep a separate accountDelegate for view-specific callbacks in Topical Dictionary/ViewModel/AccountViewModel.swift.
  • Update AccountViewController to inherit BaseViewController, move view model creation into configureViewModel() and set baseViewModel = viewModel, removing the prior closure-based error binding in Topical Dictionary/Controller/AccountViewController.swift.

Testing

  • No automated tests were executed for these changes.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant