Skip to content

Commit

Permalink
make observable public
Browse files Browse the repository at this point in the history
  • Loading branch information
JensRavens committed Sep 26, 2016
1 parent 2edd25b commit 5394d2b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
4 changes: 4 additions & 0 deletions Interstellar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/* Begin PBXBuildFile section */
8F2B8D701B07A92C0063EB9C /* Interstellar.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8F2B8D641B07A92C0063EB9C /* Interstellar.framework */; };
8F4D98571C1B1E68009A91E5 /* Observable+Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F50D39A1C1A5126002F998A /* Observable+Result.swift */; };
8F4D98581C1B1E68009A91E5 /* Observable+Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F50D39A1C1A5126002F998A /* Observable+Result.swift */; };
8F50D38F1C1A300A002F998A /* Observable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F50D38E1C1A300A002F998A /* Observable.swift */; };
8F50D3911C1A343A002F998A /* Observer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F50D3901C1A343A002F998A /* Observer.swift */; };
8F50D3931C1A3870002F998A /* ResultType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F50D3921C1A3870002F998A /* ResultType.swift */; };
Expand Down Expand Up @@ -391,6 +393,7 @@
8F50D3991C1A3DB0002F998A /* Observable.swift in Sources */,
8F5775CD1C118F6B002E134D /* Result.swift in Sources */,
8F5775DA1C118F78002E134D /* Delay.swift in Sources */,
8F4D98581C1B1E68009A91E5 /* Observable+Result.swift in Sources */,
8F5775D71C118F78002E134D /* Debounce.swift in Sources */,
8F5775D01C118F6B002E134D /* Signal.swift in Sources */,
);
Expand All @@ -407,6 +410,7 @@
8F50D3981C1A3DAF002F998A /* Observable.swift in Sources */,
8F5775CC1C118F6B002E134D /* Result.swift in Sources */,
8F5775D91C118F78002E134D /* Delay.swift in Sources */,
8F4D98571C1B1E68009A91E5 /* Observable+Result.swift in Sources */,
8F5775D61C118F78002E134D /* Debounce.swift in Sources */,
8F5775CF1C118F6B002E134D /* Signal.swift in Sources */,
);
Expand Down
12 changes: 6 additions & 6 deletions Sources/Observable+Result.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
// Copyright © 2015 nerdgeschoss GmbH. All rights reserved.
//

extension Observable where T : ResultType {
func then<U>(transform: T.Value -> Result<U>) -> Observable<Result<U>> {
public extension Observable where T : ResultType {
public func then<U>(transform: T.Value -> Result<U>) -> Observable<Result<U>> {
return map { $0.result.flatMap(transform) }
}

func then<U>(transform: T.Value -> U) -> Observable<Result<U>> {
public func then<U>(transform: T.Value -> U) -> Observable<Result<U>> {
return map { $0.result.map(transform) }
}

func then<U>(transform: T.Value throws -> U) -> Observable<Result<U>> {
public func then<U>(transform: T.Value throws -> U) -> Observable<Result<U>> {
return map { $0.result.flatMap(transform) }
}

func next(block: T.Value -> Void) -> Observable<T> {
public func next(block: T.Value -> Void) -> Observable<T> {
subscribe { result in
if let value = result.value {
block(value)
Expand All @@ -28,7 +28,7 @@ extension Observable where T : ResultType {
return self
}

func error(block: ErrorType -> Void) -> Observable<T> {
public func error(block: ErrorType -> Void) -> Observable<T> {
subscribe { result in
if let error = result.error {
block(error)
Expand Down
4 changes: 2 additions & 2 deletions Sources/Observable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ private extension Observable {
}

extension Observable {
func map<U>(transform: T->U) -> Observable<U> {
public func map<U>(transform: T->U) -> Observable<U> {
let observable = Observable<U>(options: options)
subscribe { observable.update(transform($0)) }
return observable
}

func flatMap<U>(transform: T->Observable<U>) -> Observable<U> {
public func flatMap<U>(transform: T->Observable<U>) -> Observable<U> {
let observable = Observable<U>(options: options)
subscribe { transform($0).subscribe(observable.update) }
return observable
Expand Down
6 changes: 3 additions & 3 deletions Sources/ResultType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2015 nerdgeschoss GmbH. All rights reserved.
//

protocol ResultType {
public protocol ResultType {
typealias Value

var error: ErrorType? { get }
Expand All @@ -16,15 +16,15 @@ protocol ResultType {
}

extension Result {
init(value: T?, error: ErrorType?) {
public init(value: T?, error: ErrorType?) {
if let error = error {
self = Error(error)
} else {
self = Success(value!)
}
}

var result: Result<T> {
public var result: Result<T> {
return self
}
}

0 comments on commit 5394d2b

Please sign in to comment.