Skip to content

difference between "MVC" and "MVVM" #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 49 commits into
base: mvc
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
f298266
add DataSources and Presenters
marty-suzuki Jan 23, 2018
e16f4d2
add viewModels
marty-suzuki Jan 23, 2018
44bcb71
sort project
marty-suzuki Feb 28, 2019
adeec19
Merge branch 'mvc' into mvp
marty-suzuki Feb 28, 2019
1678d8f
fix conflict
marty-suzuki Feb 28, 2019
9bde5a1
fix Main.storyboard
marty-suzuki Mar 1, 2019
41ac4a8
Merge branch 'mvc' into mvp
marty-suzuki Mar 1, 2019
04b397c
fix conflict
marty-suzuki Mar 1, 2019
af026a7
Merge branch 'mvc' into mvp
marty-suzuki Mar 1, 2019
dabba37
fix initializer
marty-suzuki Mar 1, 2019
52705ee
Merge branch 'mvp' into mvvm
marty-suzuki Mar 1, 2019
e6e2ba9
fix conflict
marty-suzuki Mar 2, 2019
9bb5b8e
Merge branch 'mvc' into mvp
marty-suzuki Mar 2, 2019
ec7f9e2
Merge branch 'mvp' into mvvm
marty-suzuki Mar 2, 2019
1149765
fix project
marty-suzuki Mar 2, 2019
a54c3d6
fix FavoriteModel
marty-suzuki Mar 3, 2019
42af1c9
fix SearchModel
marty-suzuki Mar 3, 2019
0dfe9fe
fix RepositoryModel
marty-suzuki Mar 3, 2019
65ac8f4
fix diff
marty-suzuki Mar 3, 2019
c09a019
Merge branch 'mvc' into mvp
marty-suzuki Mar 4, 2019
e2bd594
Merge branch 'mvp' into mvvm
marty-suzuki Mar 4, 2019
40358f6
Merge branch 'mvc' into mvp
marty-suzuki Feb 11, 2021
a099ef1
Fix UserRepositoryViewPresenter
marty-suzuki Feb 11, 2021
fd6ab91
Fix RepositoryViewPresenter
marty-suzuki Feb 11, 2021
b9bcd11
Fix FavoriteViewPresenter
marty-suzuki Feb 11, 2021
ddade5a
Fix SearchViewPresenter
marty-suzuki Feb 11, 2021
f519cc1
Fix injection
marty-suzuki Feb 11, 2021
3437684
Merge branch 'mvc' into mvp
marty-suzuki Feb 11, 2021
f437c3c
Merge branch 'mvp' into mvvm
marty-suzuki Feb 12, 2021
e271174
Fix ApiSession
marty-suzuki Feb 12, 2021
82f4104
Fix FavoriteModel
marty-suzuki Feb 12, 2021
fc26e10
Fix RepositoryModel
marty-suzuki Feb 12, 2021
ee8508a
Fix SearchModel
marty-suzuki Feb 12, 2021
4b28c0d
Fix Favorite
marty-suzuki Feb 12, 2021
74b9128
Fix Repository
marty-suzuki Feb 12, 2021
6e17dd2
Fix UserRepository
marty-suzuki Feb 12, 2021
acc7832
Fix Search
marty-suzuki Feb 12, 2021
51087f4
Fix injection
marty-suzuki Feb 12, 2021
4cc53eb
Fix xcodeproj
marty-suzuki Feb 12, 2021
4f3d146
Fix FavoriteViewPresenter
marty-suzuki Feb 12, 2021
ac28868
Merge branch 'mvc' into mvp
marty-suzuki Feb 12, 2021
745d7ed
Fix images
marty-suzuki Feb 12, 2021
efee15f
Merge branch 'mvc' into mvp
marty-suzuki Feb 12, 2021
c40298b
Fix images
marty-suzuki Feb 12, 2021
d0dbf62
Merge branch 'mvp' into mvvm
marty-suzuki Feb 12, 2021
ad63067
Fix images
marty-suzuki Feb 12, 2021
ef603e2
Fix images
marty-suzuki Feb 12, 2021
0016cc6
Merge branch 'mvp' into mvvm
marty-suzuki Feb 12, 2021
422e543
Fix injection
marty-suzuki Feb 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'mvc' into mvp
  • Loading branch information
marty-suzuki committed Feb 11, 2021
commit 40358f6e71ddf4f00c637d86f2d9464d8047c0a3
324 changes: 109 additions & 215 deletions iOSDesignPatternSamples.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ protocol FavoriteView: class {

final class FavoriteViewController: UIViewController, FavoriteView {
@IBOutlet private(set) weak var tableView: UITableView!

let presenter: FavoritePresenter
let dataSource: FavoriteViewDataSource

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import Combine
import GithubKit
import UIKit

protocol SearchView: class {
func reloadData()
Expand Down Expand Up @@ -71,7 +72,7 @@ final class SearchViewController: UIViewController, SearchView {
func reloadData() {
tableView.reloadData()
}

func keyboardWillShow(with keyboardInfo: UIKeyboardInfo) {
view.layoutIfNeeded()
let extra = tabBarController?.tabBar.bounds.height ?? 0
Expand Down
36 changes: 24 additions & 12 deletions iOSDesignPatternSamples/Sources/UI/Search/SearchViewPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
// Copyright © 2017年 marty-suzuki. All rights reserved.
//

import Combine
import Foundation
import GithubKit
import NoticeObserveKit
import UIKit

protocol SearchPresenter: class {
var view: SearchView? { get set }
Expand All @@ -34,9 +35,12 @@ final class SearchViewPresenter: SearchPresenter {
return model.isFetchingUsers
}

private let model = SearchModel()
private let model = SearchModel(
sendRequest: ApiSession.shared.send,
asyncAfter: { DispatchQueue.global().asyncAfter(deadline: $0, execute: $1) }
)
private var isReachedBottom: Bool = false
private var pool = Notice.ObserverPool()
private var cancellables = Set<AnyCancellable>()

init() {
self.model.delegate = self
Expand Down Expand Up @@ -68,19 +72,27 @@ final class SearchViewPresenter: SearchPresenter {
}

func viewWillAppear() {
NotificationCenter.default.nok.observe(name: .keyboardWillShow) { [weak self] in
self?.view?.keyboardWillShow(with: $0)
}
.invalidated(by: pool)
NotificationCenter.default.publisher(for: UIResponder.keyboardWillShowNotification)
.sink { [weak self] notification in
guard let info = UIKeyboardInfo(notification: notification) else {
return
}
self?.view?.keyboardWillShow(with: info)
}
.store(in: &cancellables)

NotificationCenter.default.nok.observe(name: .keyboardWillHide) { [weak self] in
self?.view?.keyboardWillHide(with: $0)
}
.invalidated(by: pool)
NotificationCenter.default.publisher(for: UIResponder.keyboardWillHideNotification)
.sink { [weak self] notification in
guard let info = UIKeyboardInfo(notification: notification) else {
return
}
self?.view?.keyboardWillHide(with: info)
}
.store(in: &cancellables)
}

func viewWillDisappear() {
pool = Notice.ObserverPool()
cancellables.removeAll()
}

func showLoadingView(on view: UIView) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class UserRepositoryViewController: UIViewController, UserRepositoryView {
@IBOutlet private(set) weak var tableView: UITableView!
@IBOutlet private(set) weak var totalCountLabel: UILabel!

let loadingView = LoadingView.makeFromNib()
let loadingView = LoadingView()

let favoritePresenter: FavoritePresenter
let userRepositoryPresenter: UserRepositoryPresenter
Expand All @@ -31,7 +31,7 @@ final class UserRepositoryViewController: UIViewController, UserRepositoryView {
self.favoritePresenter = favoritePresenter
self.userRepositoryPresenter = userRepositoryPresenter
self.dataSource = UserRepositoryViewDataSource(presenter: userRepositoryPresenter)

super.init(nibName: UserRepositoryViewController.className, bundle: nil)
hidesBottomBarWhenPushed = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import Foundation
import GithubKit
import UIKit

protocol UserRepositoryPresenter: class {
var view: UserRepositoryView? { get set }
Expand Down Expand Up @@ -40,7 +41,7 @@ final class UserRepositoryViewPresenter: UserRepositoryPresenter {
private var isReachedBottom: Bool = false

init(user: User) {
self.model = RepositoryModel(user: user)
self.model = RepositoryModel(user: user, sendRequest: ApiSession.shared.send)
self.model.delegate = self
}

Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.