Help us understand the problem. What is going on with this article?

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

More than 3 years have passed since last update.

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

サンプルコード

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 を自分なりにアレンジしたもの。

あとがき

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

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした