Skip to content

pasha010/RxObjC

Repository files navigation

RxObjC: ReactiveX for Objective-C

Build Status Version Platform codecov Carthage compatible

RxObjC is a Objective-C port of RxSwift

Current version is 1.0 ~ 2.5 RxSwift.

RxObjC 1.0 contains only core of rx, without RxCocoa module.

How install

Use CocoaPods

⚠️ IMPORTANT! For tvOS support, CocoaPods 0.39 is required. ⚠️

# Podfile
use_frameworks!

target 'YOUR_TARGET_NAME' do
    pod 'RxObjC', '~> 1.0'
end

# RxTests and RxBlocking make the most sense in the context of unit/integration tests
target 'YOUR_TESTING_TARGET' do
    pod 'RxBlocking', '~> 2.0'
    pod 'RxTests',    '~> 2.0'
end

Modules:

RxCocoa:

(see RxSwift/RxCocoa)

  • KVO extensions
  • Dealloc observing

RxBlocking:

(see RxSwift/RxBlocking) Set of blocking operators for RxObjC. These operators are mostly intended for unit/integration tests with a couple of other special scenarios where they could be useful. E.g. Waiting for observable sequence to complete before exiting command line application.

RxTests:

(see RxSwift/RxTests) Unit testing extensions for RxObjC. This library contains mock schedulers, observables, and observers that should make unit testing your operators easy as unit testing RxObjC built-in operators. This library contains everything you needed to write unit tests in the following way:

- (void)testMap {
    RxTestScheduler *scheduler = [[RxTestScheduler alloc] initWithInitialClock:0];

    RxTestableObservable *xs = [scheduler createHotObservable:@[
            next(150, @1),
            next(210, @0),
            next(220, @1),
            next(230, @2),
            next(240, @4),
            completed(300)
    ]];

    RxTestableObserver *res = [scheduler startWithObservable:[xs map:^NSNumber *(NSNumber *o) {
        return @(o.integerValue * 2);
    }]];

    NSArray *events = @[
            next(210, @(0 * 2)),
            next(220, @(1 * 2)),
            next(230, @(2 * 2)),
            next(240, @(4 * 2)),
            completed(300),
    ];
    XCTAssertEqualObjects(res.events, events);

    XCTAssertEqualObjects(xs.subscriptions, @[
            Subscription(200, 300)
    ]);
}