Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Moya-ObjectMapper.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Pod::Spec.new do |s|

s.subspec "Core" do |ss|
ss.source_files = "Source/*.swift"
ss.dependency "Moya", '~> 8.0'
ss.dependency "Moya"
ss.dependency "ObjectMapper", '~> 2.2'
ss.framework = "Foundation"
end
Expand All @@ -34,10 +34,10 @@ Pod::Spec.new do |s|
ss.dependency "RxSwift", '~> 3.1'
end

# s.subspec "ReactiveCocoa" do |ss|
# ss.source_files = "Source/ReactiveCocoa/*.swift"
# ss.dependency "Moya/ReactiveCocoa"
# ss.dependency "Moya-ObjectMapper/Core"
# ss.dependency "ReactiveSwift"
# end
s.subspec "ReactiveSwift" do |ss|
ss.source_files = "Source/ReactiveSwift/*.swift"
ss.dependency "Moya/ReactiveSwift", '~> 9.0.0-alpha.1'
ss.dependency "Moya-ObjectMapper/Core"
ss.dependency "ReactiveSwift", '~> 2.0'
end
end
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Moya-ObjectMapper

[ObjectMapper](https://github.com/Hearst-DD/ObjectMapper) bindings for
[Moya](https://github.com/Moya/Moya) for easier JSON serialization.
Includes [RxSwift](https://github.com/ReactiveX/RxSwift/) bindings as well.
Includes [RxSwift](https://github.com/ReactiveX/RxSwift/) and [ReactiveSwift](https://github.com/ReactiveCocoa/ReactiveSwift/) bindings as well.

# Installation

Expand All @@ -27,6 +27,15 @@ pod 'RxSwift'

```

The subspec if you want to use the bindings over ReactiveSwift.

```ruby
pod 'Moya-ObjectMapper/ReactiveSwift'
pod 'Moya'
pod 'ReactiveSwift'

```

# Usage

Create a `Class` or `Struct` which implements the `Mappable` protocol.
Expand Down Expand Up @@ -54,7 +63,7 @@ struct Repository: Mappable {
}
```

## 1. Without RxSwift
## 1. Without RxSwift/ReactiveSwift


```swift
Expand Down Expand Up @@ -103,6 +112,23 @@ GitHubProvider.request(.userRepositories(username))
}.addDisposableTo(disposeBag)
```

## 3. With ReactiveSwift

```swift
GitHubProvider.request(.userRepositories(username))
.mapArray(Repository.self)
.start() { event -> Void in
switch event {
case .value(let repos):
self.repos = repos
case .failed(let error):
print(error)
default:
break
}
}
```

# Contributing

Issues and pull requests are welcome!
Expand Down
2 changes: 1 addition & 1 deletion Sample/Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
9C291DA5D8E32DC7E23D2181 /* [CP] Embed Pods Frameworks */ = {
Expand Down
3 changes: 3 additions & 0 deletions Sample/Demo/GitHubAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ extension GitHub: TargetType {
return nil
}
}
public var parameterEncoding: ParameterEncoding {
return URLEncoding.default
}
public var task: Task {
return .request
}
Expand Down
10 changes: 5 additions & 5 deletions Sample/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ use_frameworks!
# Our Libraries
def libraries
pod 'Moya-ObjectMapper', :path => "../"
#pod 'Moya-ObjectMapper/ReactiveCocoa', :path => "../"
pod 'Moya-ObjectMapper/RxSwift', :path => "../"
pod 'ObjectMapper', :git => 'https://github.com/Hearst-DD/ObjectMapper'
pod 'Moya' #, :git => 'https://github.com/Moya/Moya'
#pod 'Moya-ObjectMapper/ReactiveSwift', :path => "../"
#pod 'Moya-ObjectMapper/RxSwift', :path => "../"
#pod 'ObjectMapper', :git => 'https://github.com/Hearst-DD/ObjectMapper'
#pod 'Moya' #, :git => 'https://github.com/Moya/Moya'
#pod 'ReactiveSwift', :git => 'https://github.com/ReactiveCocoa/ReactiveSwift'
pod 'RxSwift' #, :git => 'https://github.com/ReactiveX/RxSwift'
#pod 'RxSwift' #, :git => 'https://github.com/ReactiveX/RxSwift'
end

# Test Libraries
Expand Down
54 changes: 17 additions & 37 deletions Sample/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,52 +1,32 @@
PODS:
- Alamofire (4.4.0)
- Moya (8.0.3):
- Moya/Core (= 8.0.3)
- Moya-ObjectMapper (2.3.1):
- Moya-ObjectMapper/Core (= 2.3.1)
- Moya-ObjectMapper/Core (2.3.1):
- Moya (~> 8.0)
- Alamofire (4.5.0)
- Moya (8.0.5):
- Moya/Core (= 8.0.5)
- Moya-ObjectMapper (2.3.2):
- Moya-ObjectMapper/Core (= 2.3.2)
- Moya-ObjectMapper/Core (2.3.2):
- Moya
- ObjectMapper (~> 2.2)
- Moya-ObjectMapper/RxSwift (2.3.1):
- Moya-ObjectMapper/Core
- Moya/RxSwift
- RxSwift (~> 3.1)
- Moya/Core (8.0.3):
- Moya/Core (8.0.5):
- Alamofire (~> 4.1)
- Result (~> 3.0)
- Moya/RxSwift (8.0.3):
- Moya/Core
- RxSwift (~> 3.0)
- ObjectMapper (2.2.5)
- Result (3.2.1)
- RxSwift (3.4.0)
- ObjectMapper (2.2.8)
- Result (3.2.3)

DEPENDENCIES:
- Moya
- Moya-ObjectMapper (from `../`)
- Moya-ObjectMapper/RxSwift (from `../`)
- ObjectMapper (from `https://github.com/Hearst-DD/ObjectMapper`)
- RxSwift

EXTERNAL SOURCES:
Moya-ObjectMapper:
:path: ../
ObjectMapper:
:git: https://github.com/Hearst-DD/ObjectMapper

CHECKOUT OPTIONS:
ObjectMapper:
:commit: 0b38c787d442714223604919f113d84cd55f5427
:git: https://github.com/Hearst-DD/ObjectMapper

SPEC CHECKSUMS:
Alamofire: dc44b1600b800eb63da6a19039a0083d62a6a62d
Moya: d3721622e3cc0cc2f038d69a258686f0b66e7252
Moya-ObjectMapper: 868c88169d20e5b48bff160d3730252e6ac33394
ObjectMapper: d4cd68f462d89a878a1c2c480f389ec5f9a7ea04
Result: 2453a22e5c5b11c0c3a478736e82cd02f763b781
RxSwift: 3789a1af753002a14edecdb698a2424624296a9c
Alamofire: f28cdffd29de33a7bfa022cbd63ae95a27fae140
Moya: c37eec09a098ba9991b5a963b291fc5704bdb9ef
Moya-ObjectMapper: 6796feb29c8a1761722b96ea5ffa6893b6e0c15b
ObjectMapper: 3d571bb5af471c779e1160828cd9ad5c4ef90958
Result: 128640a6347e8d2ae48b142556739a2d13f90ce6

PODFILE CHECKSUM: 9299419ef67b47dd9a0ab9cd611dc44ff80199a2
PODFILE CHECKSUM: b48a2cd0c99cd97066deb40b55e6cf4a8a900bec

COCOAPODS: 1.2.0
COCOAPODS: 1.2.1
Loading