Giter VIP home page Giter VIP logo

swiftui-mvvm's Introduction

SwiftUI-MVVM

One of the biggest idea for having MVVM is that most of data flow can be testable. Data binding in view layer by SwiftUI is awesome. However, this project has view model layer to make it testable as much as possible.
This idea can be achieved by Flux or Redux as well, but I chose MVVM first because it's handy.

Requirements

Xcode 11.0 Beta 5+
Swift 5.1+

More examples

See other architectures as well

swiftui-mvvm's People

Contributors

kitasuke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swiftui-mvvm's Issues

Overcomplicated ViewModel

This is mostly a question about the code for: https://github.com/kitasuke/SwiftUI-MVVM/blob/master/SwiftUI-MVVM/ViewModels/RepositoryListViewModel.swift
I see that you are organising bindings in Outputs and Inputs... in general you are adding a level of complexity that is very difficult to understand and read.

Take as example this step in the bindingInputs() method:

    let responseStream = responsePublisher
        .share()
        .subscribe(responseSubject)

and this one in the bindingOutputs() method:

    let repositoriesStream = responseSubject
        .map { $0.items }
        .assign(to: \.repositories, on: self)

Why don't you just merge the two writing just:

    let responseStream = responsePublisher  // Taken from bindingInputs()
        .map { $0.items }                                      // Taken from bindingOutputs()
        .assign(to: \.repositories, on: self)         // Taken from bindingOutputs()

Which is the benefit of having it done in two steps? I can't understand why putting a subject as connection between these two parts, while you could have subscribed with the .assign directly from the responsePublisher.

(I took hours to understand what you were doing here :P )

thank you for sharing your code! this is one of the few examples that shows a real implementation with Combine!

RepositoryListViewModel init called multiple times

Firstly thank you for sharing your code, secondly i couldn't help but noticing that RepositoryListViewModel creates multiple instances at launch and a bunch of others on scrolling.
is that a bug in Xcode or something else i should be aware when using swiftUI in production apps.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.