LoginSignup
174
164

More than 5 years have passed since last update.

RxSwift で MVVM パターンを作るときに参考になるサンプルコードまとめ

Last updated at Posted at 2015-12-04

公開されているものがまだ少ないのでまとめます。
見つけ次第 更新します。

サンプルコード

artsy/eidolon

artsy/eidolon

オープンソースの iOS アプリ。
元々は RAC 2 で作っていたものを RxSwift で書き換えたとのこと。

その PR がこちら:

Migrates from ReactiveCocoa 2.x API to RxSwift #569
https://github.com/artsy/eidolon/pull/569

sergdort/RxMarvel

sergdort/RxMarvel

Keeping this in mind I like to think about ViewModel as a “Black Box” which accepts some UI triggers, other dependencies and apply some Rx operators
https://medium.com/@SergDort/viewmodel-in-rxswift-world-13d39faa2cf5

devxoul/RxTodo

devxoul/RxTodo

Philisophy

  • View doesn't have control flow. View cannot modify the data. View only knows how to map the data.
  • View doesn't know what ViewModel does. View can only communicate to ViewModel about what View did.
  • Model is hidden by ViewModel. ViewModel only exposes the minimum data so that View can render.

yuzushioh/sandbox

yuzushioh/sandbox

発表資料があります

tryswift/RxPagination

tryswift/RxPagination

RxSwift と APIKit, Himotoki を用いた実装例。
try! Swift での発表内容 もまとまってます。

RxSwift/RxExample

WikipediaImageSearch

TableView と API クライアントの実装例。

おまけ

RxSwiftは使っていないですが、MVVM パターンのサンプルコードもまとめてみます。

NatashaTheRobot/ProtocolOrientedMVVMExperimentSwift

NatashaTheRobot/ProtocolOrientedMVVMExperimentSwift

Natasha the Robot will walk you through her process of learning and using protocol-oriented programming to leverage Swift 2.0’s power and create beautiful, robust code.
https://realm.io/news/doios-natasha-murashev-protocol-oriented-mvvm/

発表内容にある再利用可能な protocol を用意して ViewModel を組み立てるアプローチが参考になります。

kumapo/ProtocolOrientedMVVM

kumapo/ProtocolOrientedMVVM

NatashaTheRobot/ProtocolOrientedMVVMExperimentSwift を自分なりにアレンジしたもの。

あとがき

もし よさげなサンプルコードを見つけた方がいましたらコメントにてお知らせください。

174
164
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
174
164