Skip to content
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

Mvvm #14

Open
wants to merge 61 commits into
base: svastven
Choose a base branch
from
Open

Mvvm #14

wants to merge 61 commits into from

Conversation

vendulasvastal
Copy link

  • logika ve View Modelech
  • propojení View Modelů s View Controllery
  • oddělení Views od View Controllerů
  • logika Flow Controlleru


override func bindViewToViewModel(v: UIView, vm: AppViewModel) {
let balanceView = v as! BalanceView
let vm = vm as! BalanceViewModel
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tyjo asi chápu o co tady jde, ale tohle by chtělo vyřešit nějak jinak. Jednak to není zrovna safe a jednak sis vlastně neušetřila moc žádnou práci.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jako cela ta overridnuta funkce, je nesmysl, nebo to castovani?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No pojďme diskutovat nejdřív o tom, proč ta overriden funkce..? Nebo jako proč je overriden chápu, ale proč existuje v tom baseVC v té obecné podobě? Co tím sleduješ? Co to přináší za výhodu?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overriden protoze ji volam ve view did load a kdyby bylo view controlleru vice, tak bych delala v kazdem to same

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noooo a teď děláš v každém to samé (cast na konkrétní view a VM) a navíc s vykřičníkama 😛 Nápad chápu, ale nepřijde mi, že bys tím něco vyhrála.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

co takhle?

class BaseVC<T> {
    init(vm: T) {
        bind(to: vm)
    }
    
    func bind(to: T) {
        print("base print: \(to)")
    }
}

class SomeVC: BaseVC<Int> {
    override func bind(to: Int) {
        print("int print: \(to)")
    }
}

let foo = SomeVC(vm: 1)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

joo, to vypada moc dobre 👍

return resultRequestBalancePage.map { [weak self] in
guard let strongSelf = self, let balancePage = $0.element, $0.info == .loggedIn else {
SVProgressHUD.showError(withStatus: "Failed".localized)
SVProgressHUD.dismiss(withDelay: 1.0)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ten progress hud z VM není moc good. Když ti teď řeknu ať to vyměníš za nějaký custom view, tak jseš nahraná. Loading indicator je UI, tedy z těch písmenek MVVM je to to View, tak ho nedávej do VM 😏

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jasne, makes sense, ja prave vahala jak to s tim udelat :D fixnu

import UIKit

extension UIImage {
enum ImageId: String {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Znáš SwiftGen? 🙂

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

znam, dam ho tam

@LukasHromadnik
Copy link
Contributor

jak to s tebou vypadá? :)

@vendulasvastal
Copy link
Author

vendulasvastal commented Jul 10, 2019

jak to s tebou vypadá? :)

mela jsem jeste ted moc honku, ale opet na to zase koukam
jinak jako co do funkcnosti tak az na ten logout to je hotove, ale jeste bych chtela trochu kouknout na tu strukturu a na widget

@LukasHromadnik
Copy link
Contributor

Chceš na tom ještě pracovat? 😄 už je to dost velký, ale klidně to zase rozhýbu 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants