Skip to content

Commit

Permalink
Update README and podspec.
Browse files Browse the repository at this point in the history
  • Loading branch information
lm2343635 committed Jun 19, 2019
1 parent 2654609 commit 5d53b9e
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 12 deletions.
31 changes: 25 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,16 @@ RxController provides the the following basic view controller and view model cla

These classes make it easy to transfer data among the flows, the parent view models and the child view models.

## Documentaion
## Recommended guideline

We recommended to develop a MMVM-C based on **RxController**, **RxFlow** and **RxSwift** with this guideline.
It better to read the documentation of RxController, RxFlow and RxSwift at first, if you are not familiar with them.

- Chapter 1: [Introduction](https://github.com/lm2343635/RxController/blob/master/document/chapter1-introduction.md)
- Chapter 2: [Using RxFlow](https://github.com/lm2343635/RxController/blob/master/document/chapter2-rxflow.md)
- Chapter 3: [View controller and view model](https://github.com/lm2343635/RxController/blob/master/document/chapter3-viewcontroller-viewmodel.md)

## Documentation

RxController is available through [CocoaPods](https://cocoapods.org). To install
it, simply add the following line to your Podfile:
Expand Down Expand Up @@ -76,11 +85,21 @@ With `RxChildViewModel`, we can exchange data among parent and child view models
Use the following method to add a child view controller to the root view or a customized view of its parent controller.

```Swift
// Add a child view controller to the root view of its parent controller.
func addRxChild<ViewModel: RxViewModel>(_ childController: RxViewController<ViewModel>, completion: ((UIView) -> Void)? = nil)

// add a child view controller to a customized view of its parent controller.
func addRxChild<ViewModel: RxViewModel>(_ childController: RxViewController<ViewModel>, to view: UIView, completion: ((UIView) -> Void)? = nil)
/**
Add a child view controller to the root view of the parent view controller.
@param childController: a child view controller.
*/
override open func addChild(_ childController: UIViewController)

/**
Add a child view controller to the a container view of the parent view controller.
The edges of the child view controller is same as the container view by default.
@param childController: a child view controller.
@param containerView: a container view of childController.
*/
open func addChild(_ childController: UIViewController, to containerView: UIView)
```

To transfer data among view models, we define some events with a struct in the parent view model.
Expand Down
2 changes: 1 addition & 1 deletion RxController.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'RxController'
s.version = '0.5'
s.version = '0.6'
s.summary = 'A library for developing with MVVM-C based on RxFlow and RxSwift.'

# This description is used to generate tags and improve search results.
Expand Down
11 changes: 7 additions & 4 deletions RxController/Classes/RxViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ open class RxViewController<ViewModel: RxViewModel>: UIViewController, RxViewCon
}

/**
Add a child view controller to the root view of this parent view controller.
Add a child view controller to the root view of the parent view controller.
@param childController: a child view controller.
*/
Expand All @@ -101,16 +101,19 @@ open class RxViewController<ViewModel: RxViewModel>: UIViewController, RxViewCon
}

/**
Add a child view controller to the root view of this parent view controller.
Add a child view controller to the a container view of the parent view controller.
The edges of the child view controller is same as the container view by default.
@param childController: a child view controller.
@param containerView: a container view of childController.
*/
open func addChild(_ childController: UIViewController, to containerView: UIView) {
super.addChild(childController)
// Add child view controller to the parent view controller.
// Add child view controller to a container view of the parent view controller.
containerView.addSubview(childController.view)
childController.didMove(toParent: self)


// Create constraints for the root view of the child view controller.
childController.view.translatesAutoresizingMaskIntoConstraints = false
childController.view.leftAnchor.constraint(equalTo: containerView.leftAnchor).isActive = true
childController.view.rightAnchor.constraint(equalTo: containerView.rightAnchor).isActive = true
Expand Down
2 changes: 1 addition & 1 deletion document/chapter1-introduction.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Chatper 1: Indroduction
# Chapter 1: Introduction

This guideline introduces how to develop a MVVM-C app based the RxController library.
We will call MVVM directly in this guideline, it represents MVVM-C design pattern.
Expand Down
1 change: 1 addition & 0 deletions document/chapter2-rxflow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Chapter 2: Using RxFlow
1 change: 1 addition & 0 deletions document/chapter3-viewcontroller-viewmodel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Chapter 3: View controller and view model

0 comments on commit 5d53b9e

Please sign in to comment.