Skip to content

Latest commit

 

History

History
78 lines (57 loc) · 1.67 KB

README.md

File metadata and controls

78 lines (57 loc) · 1.67 KB

RxSwiftSugar

This library supports convenient operators of RxSwift / RxCooca.

The list of supported operators is here.

Requirements

  • Xcode 12.x
  • Swift 5.x

Installation

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/Woin2ee-Modules/RxSwiftSugar.git", .upToNextMajor(from: "1.0.0"))
]

Supported operators

func asDriverOnErrorJustComplete() -> Driver<Element>
    
func asSignalOnErrorJustComplete() -> Signal<Element>
// when Element == Void

func asDriverOnErrorJustNext() -> Driver<Void>

func asSignalOnErrorJustNext() -> Signal<Void>
func mapToVoid() -> AnyObservableType<Void>

func mapToAny() -> AnyObservableType<Any>
    
func doOnNext(_ block: ((Element) throws -> Void)?) -> AnyObservableType<Element>

func doOnCompleted(_ block: (() throws -> Void)?) -> AnyObservableType<Element>

func doOnSuccess(_ block: ((Element) throws -> Void)?) -> Single<Element>
func startWith(_ block: () -> Element) -> SharedSequence<SharingStrategy, Element>

.startWith {
    if text.isEmpty {
        return "A"
    } else {
        return "B"
    }
}
func unwrapOrThrow<Result>() -> AnyObservableType<Result>

array
    .map(\.first)
    .unwrapOrThrow() // If nil, throw error.

Completable

func andThenJustNext() -> Single<Void>

signOut() // Will return `CompletableEvent.completed`
    .andThenJustNext() // Use it if want `next` event.
func catchAndThenJustNext() -> Single<Void>

delete() // Will return `CompletableEvent.error`
    .catchAndThenJustNext() // Use it if want `next` event.