|
8 | 8 |
|
9 | 9 | import Foundation |
10 | 10 |
|
11 | | -// MARK: - basic viper protocols |
| 11 | +// MARK: - interfaces |
12 | 12 |
|
13 | | -public protocol ModuleInterface { |
14 | | - |
15 | | -} |
16 | | - |
17 | | -public protocol RouterInterface: class { |
18 | | - |
19 | | -} |
20 | | - |
21 | | -public protocol PresenterInterface: class { |
22 | | - |
23 | | -} |
24 | | - |
25 | | -public protocol InteractorInterface: class { |
| 13 | +public protocol RouterPresenterInterface: class { |
26 | 14 |
|
27 | 15 | } |
28 | 16 |
|
29 | | -public protocol ViewInterface: class { |
| 17 | +public protocol InteractorPresenterInterface: class { |
30 | 18 |
|
31 | 19 | } |
32 | 20 |
|
33 | | -public protocol EntityInterface { |
| 21 | +public protocol PresenterRouterInterface: class { |
34 | 22 |
|
35 | 23 | } |
36 | 24 |
|
37 | | -// MARK: - "i/o" transitions |
38 | | - |
39 | | -public protocol RouterPresenterInterface { |
| 25 | +public protocol PresenterInteractorInterface: class { |
40 | 26 |
|
41 | 27 | } |
42 | 28 |
|
43 | | -public protocol InteractorPresenterInterface { |
| 29 | +public protocol PresenterViewInterface: class { |
44 | 30 |
|
45 | 31 | } |
46 | 32 |
|
47 | | -public protocol PresenterRouterInterface { |
| 33 | +public protocol ViewPresenterInterface: class { |
48 | 34 |
|
49 | 35 | } |
50 | 36 |
|
51 | | -public protocol PresenterInteractorInterface { |
52 | | - |
53 | | -} |
| 37 | +// MARK: - viper |
54 | 38 |
|
55 | | -public protocol PresenterViewInterface { |
56 | | - |
57 | | -} |
58 | | - |
59 | | -public protocol ViewPresenterInterface { |
60 | | - |
61 | | -} |
62 | | - |
63 | | -// MARK: - generic interfaces |
64 | | - |
65 | | -public protocol GenericRouterInterface: RouterInterface & |
66 | | - RouterPresenterInterface { |
| 39 | +public protocol RouterInterface: RouterPresenterInterface { |
67 | 40 | associatedtype PresenterRouter |
68 | | - |
| 41 | + |
69 | 42 | var presenter: PresenterRouter! { get set } |
70 | 43 | } |
71 | 44 |
|
72 | | -public protocol GenericInteractorInterface: InteractorInterface & |
73 | | - InteractorPresenterInterface { |
| 45 | +public protocol InteractorInterface: InteractorPresenterInterface { |
74 | 46 | associatedtype PresenterInteractor |
75 | 47 |
|
76 | 48 | var presenter: PresenterInteractor! { get set } |
77 | 49 | } |
78 | 50 |
|
79 | | -public protocol GenericPresenterInterface: PresenterInterface & |
80 | | - PresenterRouterInterface & |
81 | | - PresenterInteractorInterface & |
82 | | - PresenterViewInterface |
83 | | -{ |
| 51 | +public protocol PresenterInterface: PresenterRouterInterface & PresenterInteractorInterface & PresenterViewInterface { |
84 | 52 | associatedtype RouterPresenter |
85 | 53 | associatedtype InteractorPresenter |
86 | 54 | associatedtype ViewPresenter |
87 | | - |
| 55 | + |
88 | 56 | var router: RouterPresenter! { get set } |
89 | 57 | var interactor: InteractorPresenter! { get set } |
90 | 58 | var view: ViewPresenter! { get set } |
91 | 59 | } |
92 | 60 |
|
93 | | -public protocol GenericViewInterface: ViewInterface & |
94 | | - ViewPresenterInterface { |
| 61 | +public protocol ViewInterface: ViewPresenterInterface { |
95 | 62 | associatedtype PresenterView |
96 | 63 |
|
97 | 64 | var presenter: PresenterView! { get set } |
98 | 65 | } |
99 | 66 |
|
| 67 | +public protocol EntityInterface { |
| 68 | + |
| 69 | +} |
| 70 | + |
| 71 | +// MARK: - module |
| 72 | + |
| 73 | +public protocol ModuleInterface { |
100 | 74 |
|
101 | | -public protocol GenericModuleInterface: ModuleInterface { |
102 | | - associatedtype View where View: GenericViewInterface |
103 | | - associatedtype Presenter where Presenter: GenericPresenterInterface |
104 | | - associatedtype Router where Router: GenericRouterInterface |
105 | | - associatedtype Interactor where Interactor: GenericInteractorInterface |
| 75 | + associatedtype View where View: ViewInterface |
| 76 | + associatedtype Presenter where Presenter: PresenterInterface |
| 77 | + associatedtype Router where Router: RouterInterface |
| 78 | + associatedtype Interactor where Interactor: InteractorInterface |
106 | 79 |
|
107 | | - func compose(view: View, presenter: Presenter, router: Router, interactor: Interactor) |
| 80 | + func assemble(view: View, presenter: Presenter, router: Router, interactor: Interactor) |
108 | 81 | } |
109 | 82 |
|
110 | | -public extension GenericModuleInterface { |
| 83 | +public extension ModuleInterface { |
111 | 84 |
|
112 | | - /** |
113 | | - Composes the VIPER module |
114 | | - |
115 | | - This method will set all the required pointers |
116 | | - */ |
117 | | - func compose(view: View, presenter: Presenter, router: Router, interactor: Interactor) { |
| 85 | + func assemble(view: View, presenter: Presenter, router: Router, interactor: Interactor) { |
118 | 86 | view.presenter = (presenter as! Self.View.PresenterView) |
119 | 87 |
|
120 | 88 | presenter.view = (view as! Self.Presenter.ViewPresenter) |
|
0 commit comments