Created
May 23, 2020 22:13
-
-
Save Plnda/dbefe027513ca83d96b951abc3f156d9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
protocol WorkProtocol: class { | |
func work() | |
} | |
class ViewModel { | |
weak var delegate: WorkProtocol? | |
} | |
struct Bar { | |
let name: String = "test" | |
} | |
struct Foo { | |
let bar: Bar | |
} | |
class ViewController: UIViewController { | |
@Injected var viewModel: ViewModel | |
@Injected var foo: Foo | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
print(foo.bar.name) | |
viewModel.delegate = self | |
// Call implementation | |
viewModel.delegate?.work() | |
} | |
override func viewDidAppear(_ animated: Bool) { | |
super.viewDidAppear(animated) | |
present(ViewController2(), animated: true, completion: nil) | |
} | |
} | |
extension ViewController: WorkProtocol { | |
func work() { | |
print("Im working!") | |
} | |
} | |
class ViewController2: UIViewController { | |
@Injected var viewModel: ViewModel | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
viewModel.delegate?.work() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment