-
Notifications
You must be signed in to change notification settings - Fork 175
/
MainPresenter.swift
48 lines (40 loc) · 1.17 KB
/
MainPresenter.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import UIKit
import Combine
final class MainPresenter {
private let interactor: MainInteractor
private let router: MainRouter
private var disposeBag = Set<AnyCancellable>()
var tabs: [TabPage] {
return TabPage.allCases
}
var viewControllers: [UIViewController] {
return [
router.walletViewController(),
router.notificationsViewController(),
]
}
init(router: MainRouter,
interactor: MainInteractor) {
defer {
setupInitialState()
}
self.router = router
self.interactor = interactor
}
}
// MARK: - Private functions
extension MainPresenter {
private func setupInitialState() {
interactor.pushRequestPublisher
.receive(on: DispatchQueue.main)
.sink { [weak self] request in
self?.router.present(pushRequest: request)
}.store(in: &disposeBag)
interactor.sessionProposalPublisher
.receive(on: DispatchQueue.main)
.sink { [weak self] proposal in
self?.router.present(proposal: proposal)
}
.store(in: &disposeBag)
}
}