tailec / ios-architecture Goto Github PK
View Code? Open in Web Editor NEWA collection of iOS architectures - MVC, MVVM, MVVM+RxSwift, VIPER, RIBs and many others
License: MIT License
A collection of iOS architectures - MVC, MVVM, MVVM+RxSwift, VIPER, RIBs and many others
License: MIT License
Hi,
I have problem when I want to build the RXswift project in this Repository. I had cloned this repository and installed / updated the pods. When I build the project, those are some error occurred.
The error is: Static member 'load' cannot be used on instance of type 'AtomicInt'
What should I do to fix the error?
Hi, @tailec
ViewModel has a reference of abstracted ViewController as Delegate in mvvm-delegation.
It means that is not MVVM, actually that is MVP.
@amadeu01 mentioned in #2 (comment) , too.
I have a doubt about #2 (comment) .
I think in MVP, presenter can have access to view (imports UIKit) but view models in MVVM are forbidden to do that.
I think differences between MVP and MVVM are those have references of View directly or not.
Presenter has a reference of View (or ViewController) that is abstracted as protocol in almost cases.
To reflect state of Presenter, it calls method of abstructed View.
protocol CounterView {
func didChangeCount(_ presenter: CounterPresenter, count: Int)
}
class CounterViewController: UIViewController, CounterView {
let presenter: CounterPresenter
let countLabel: UILabel
override func viewDidLoad() {
super.viewDidLoad()
presenter.view = self
}
func countUp() {
presenter.countUp()
}
}
extension CounterViewController: CounterView {
func didChangeCount(_ presenter: CounterPresenter, count: Int) {
countLabel?.text = "\(count)"
}
}
class CounterPresenter {
private(set) var count: Int = 0 {
didSet {
view?.didChangeCount(self, count: count)
}
}
weak var view: CounterView?
func countUp() {
count += 1
}
}
ViewModel must not depend on View (or ViewController).
Even if View is abstracted as Protocol, ViewModel must not depend on them.
To reflect state of ViewModel, it notifies changes of state with closure (or RxSwift.Observable and so on).
Closure is implemented outside of ViewModel, therefore ViewModel does not depend on View directly.
class CounterViewController: UIViewController {
let viewModel: CounterViewModel
let countLabel: UILabel
override func viewDidLoad() {
super.viewDidLoad()
viewModel.countChanged = { [weak countLabel] count in
countLabel?.text = "\(count)"
}
}
func countUp() {
viewModel.countUp()
}
}
class CounterViewModel {
private(set) var count: Int = 0 {
didSet {
countChanged?(count)
}
}
var countChanged: ((Int) -> Void)?
func countUp() {
count += 1
}
}
Please add clean swift (VIP) architecture... :)
https://hackernoon.com/introducing-clean-swift-architecture-vip-770a639ad7bf
Could you explain more about this implementation.
func transform(input: SearchViewModel.Input) -> SearchViewModel.Output {
I could not understand well. The ViewModel
is some sort of pipeline that for an input it generates one output?
let deltaDelay = fabs(previousRun.timeIntervalSinceNow) > delay ? 0 : delay
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.