Skip to content

A Swift project that leverages Reactive libraries, caching, and object mapping, whilst using the MVVM + Coordinator Architecture

License

Notifications You must be signed in to change notification settings

yarneo/SwiftReactiveMVVM

Repository files navigation

SwiftReactiveMVVM

A Swift 4 project that leverages Reactive libraries, caching, and object mapping, whilst using the MVVM + Coordinator Architecture

The idea behind this mini-project is to create a good skeleton for developers who want to leverage strong and useful 3rd party libraries to facilitate a Reactive driven app, that uses the Model / View Model / View + Coordinators architecture.

The 3rd party libraries used in this project:

Introduction

Recently I was inspired by the new wave of newer better architectures than the archaic Model / View / View Controller. These newer architectures are better for numerous reasons, if for easier testing, better modularity, create a less bulky view controller, make code collaboration easier, etc. One architecture that really stuck out is the MVVM + Coordinators approach. I urge you to read more about it here: https://medium.com/@giovannyorozco24/mvvm-and-coordinator-pattern-together-8920fc0f1f55 and here: https://academy.realm.io/posts/mobilization-lukasz-mroz-mvvm-coordinators-rxswift/ .

If you will notice, usually this architecture is mentioned alongside with "Reactive Programming". It definitely isn't supposed to come as part of the architecture, but reactive programming seems to resonate well with MVVM. If you have never heard of reactive programming before, you should read a few tutorials (https://www.raywenderlich.com/158026/introducing-rxswift-reactive-programming-swift) before starting to use it, as it is something you really need to wrap your head around initially.

Project Details

I have decided to make use of an open and public API called https://uinames.com/. With this API, I display a table of random users which then you can click on each user to see more details.

This entire project is using reactive programming and the project folder hierarchy is split into folders that fit the MVVM+C pattern: Models, View Models, Views, Networking, Coordinator.

  • SDWebImage is used to load and cache the image URLS into images for each user that is displayed.
  • Realm is used to store the users information on disk if there is network issues and we wish to have the data offline.
  • Moya is used for easier use and encapsulation of the networking model.
  • ObjectMapper is used to make the parsing of the returned JSON from the server into a Swift Object as easy as possible.
  • RxSwift is used for making everything reactive :)

screen shot 2017-12-17 at 11 40 59 am

screen shot 2017-12-17 at 11 41 28 am

Feel free to contribute to this project if you see any places for improvement, happy Swifting!

About

A Swift project that leverages Reactive libraries, caching, and object mapping, whilst using the MVVM + Coordinator Architecture

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published