Add new pods.

- RxSwift
- RXCocoa
This commit is contained in:
Qiu Yuzhou
2017-03-17 23:08:52 +08:00
parent 0bbc55748c
commit 24836d203a
227 changed files with 23130 additions and 572 deletions

View File

@ -0,0 +1,58 @@
//
// Bag+Rx.swift
// RxSwift
//
// Created by Krunoslav Zaher on 10/19/16.
// Copyright © 2016 Krunoslav Zaher. All rights reserved.
//
import Foundation
// MARK: forEach
extension Bag where T: ObserverType {
/// Dispatches `event` to app observers contained inside bag.
///
/// - parameter action: Enumeration closure.
func on(_ event: Event<T.E>) {
if _onlyFastPath {
_value0?.on(event)
return
}
let value0 = _value0
let dictionary = _dictionary
if let value0 = value0 {
value0.on(event)
}
if let dictionary = dictionary {
for element in dictionary.values {
element.on(event)
}
}
}
}
/// Dispatches `dispose` to all disposables contained inside bag.
func disposeAll(in bag: Bag<Disposable>) {
if bag._onlyFastPath {
bag._value0?.dispose()
return
}
let value0 = bag._value0
let dictionary = bag._dictionary
if let value0 = value0 {
value0.dispose()
}
if let dictionary = dictionary {
for element in dictionary.values {
element.dispose()
}
}
}

View File

@ -0,0 +1,24 @@
//
// String+Rx.swift
// RxSwift
//
// Created by Krunoslav Zaher on 12/25/15.
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
import Foundation
extension String {
/// This is needed because on Linux Swift doesn't have `rangeOfString(..., options: .BackwardsSearch)`
func lastIndexOf(_ character: Character) -> Index? {
var index = endIndex
while index > startIndex {
index = self.index(before: index)
if self[index] == character {
return index
}
}
return nil
}
}