github ReactiveX/RxSwift 2.0.0-rc.0
on(.Next("2.0.0"))

latest releases: 6.6.0, 6.5.0, 5.1.3...
pre-release8 years ago

This is RxSwift 2.0 RC.

We have collected all of the feedback regarding 2.0.0 alpha and beta versions and tried to include it in this version of 2.0.0 API.

We've tried to mark all of the deprecated APIs and provide a helpful message how to transition to release version of library.
Once 2.0.0 is released, all deprecated APIs will be removed.

This RC can be always used as a transition guide even after we release 2.0.0 version.

Changes are cosmetic in nature, no behavior has been changed.

This RC contains all of the APIs we plan to ship in the next day or two, so in case you see some kind of problem with some part, please inform us.

Changes included in this release are intended to make the API more consistent internally and between Rx versions.

Major changes include changing from using free functions to create observable sequences to using factory methods:

Observable.just(1)

... instead of

just(1)

In case you want to use old behavior, you'll need to create those aliases to Observable factory methods in your project.

Major changes also include Variable not being observable directly, but through asObservable interface. In that way we can always complete the sequence once nothing is referencing particular variable instance. That should make it's behavior consistent with ControlProperty and ControlEvent.

Here is a list full list of all significant changes ...

Features

  • Adds generic public func rx_sentMessage(selector: Selector) -> Observable<[AnyObject]> that enables observing of messages
    sent to any object. (This is enabled if DISABLE_SWIZZLING isn't set).
    • use cases like cell.rx_sentMessage("prepareForReuse") are now supported.
  • Linux support (proof of concept, but single threaded mode works)
  • Initial support for Swift Package Manager
    • works on Linux (RxSwift, RxBlocking, RxTests)
    • doesn't work on OSX because it can't compile RxCocoa and RxTests (because of inclusion of XCTest extensions), but OSX has two other package managers and manual method.
    • Project content is linked to Sources automagically using custom tool
    • more info in Documentation/Linux.md
  • Adds VirtualTimeScheduler to RxSwift
  • Adds HistoricalScheduler to RxSwift
  • Improves performance of virtual schedulers using priority queue.
  • Adds new RxTests library to enable testing of custom Rx operators.
    This library contains everything needed to write unit tests in the following way:
func testMap() {
    let scheduler = TestScheduler(initialClock: 0)

    let xs = scheduler.createHotObservable([
        next(150, 1),
        next(210, 0),
        next(220, 1),
        next(230, 2),
        next(240, 4),
        completed(300)
        ])

    let res = scheduler.start { xs.map { $0 * 2 } }

    let correctEvents = [
        next(210, 0 * 2),
        next(220, 1 * 2),
        next(230, 2 * 2),
        next(240, 4 * 2),
        completed(300)
    ]

    let correctSubscriptions = [
        Subscription(200, 300)
    ]

    XCTAssertEqual(res.events, correctEvents)
    XCTAssertEqual(xs.subscriptions, correctSubscriptions)
}
  • Adds test project for RxExample-iOS that demonstrates how to easily write marble tests using RxTests project.
let (
    usernameEvents,
    passwordEvents,
    repeatedPasswordEvents,
    loginTapEvents,

    expectedValidatedUsernameEvents,
    expectedSignupEnabledEvents
) = (
    scheduler.parseEventsAndTimes("e---u1----u2-----u3-----------------", values: stringValues).first!,
    scheduler.parseEventsAndTimes("e----------------------p1-----------", values: stringValues).first!,
    scheduler.parseEventsAndTimes("e---------------------------p2---p1-", values: stringValues).first!,
    scheduler.parseEventsAndTimes("------------------------------------", values: events).first!,

    scheduler.parseEventsAndTimes("e---v--f--v--f---v--o----------------", values: validations).first!,
    scheduler.parseEventsAndTimes("f--------------------------------t---", values: booleans).first!
)
  • Adds example app for GitHub signup example that shows the same example written with and without Driver.
  • Documents idea behind units and Driver in Units.md.
  • Example of table view with editing is polished to use more functional approach.
  • Adds deferred to Driver unit.
  • Removes implicitly unwrapped optionals from CLLocationManager extensions.
  • Removes implicitly unwrapped optionals from NSURLSession extensions.
  • Polishes the debug operator format.
  • Adds optional cellType parameter to Table/Collection view rx_itemsWithCellIdentifier method.
  • Polish for calculator example in RxExample app.
  • Documents and adds unit tests for tail recursive optimizations of concat operator.
  • Moves Event equality operator to RxTests project.
  • Adds seealso references to reactivex.io.
  • Polishes headers in source files and adds tests to enforce standard header format.
  • Adds driveOnScheduler to enable scheduler mocking for Driver during unit tests.
  • Adds assertions to drive* family of functions that makes sure they are always called from main thread.
  • Refactoring and polishing of internal ObjC runtime interception architecture.

Deprecated

  • Changes ConnectableObservable, generic argument is now type of elements in observable sequence and not type of underlying subject. (BREAKING CHANGE)

  • Removes RxBox and RxMutable box from public interface. (BREAKING CHANGE)

  • SchedulerType now isn't parametrized on Time and TimeInterval.

  • Deprecates Variable implementing ObservableType in favor of asObservable().

    • Now variable also sends .Completed to observable sequence returned from asObservable when deallocated.
      If you were (mis)using variable to return single value
      Variable(1).map { x in ... }
      ... you can just use just operator
      Observable.just(1).map { x in ... }
  • Deprecates free functions in favor of Observable factory methods, and deprecates versions of operators with hidden external parameters (scheduler, count) in favor of ones with explicit parameter names.
    E.g.

    Observable.just(1) instead of just(1)

    Observable.empty() instead of empty()

    Observable.error() instead of failWith()

    Observable.of(1, 2, 3) instead of sequenceOf(1, 2, 3)

    .debounce(0.2, scheduler: MainScheduler.sharedInstance) instead of .debounce(0.2, MainScheduler.sharedInstance)

    Observable.range(start:0, count: 10) instead of range(0, 10)

    Observable.generate(initialState: 0, condition: { $0 < 10 }) { $0 + 1 } instead of generate(0, condition: { $0 < 10 }) { $0 + 1 }

    Observable<Int>.interval(1, scheduler: MainScheduler.sharedInstance) instead of interval(1, MainScheduler.sharedInstance)

    ...

    If you want to continue using free functions form, you can define your free function aliases for Observable factory methods (basically copy deprecated methods).

  • Deprecates UIAlertView extensions.

    • These extensions could be stored locally if needed.
  • Deprecates UIActionSheet extensions.

    • These extensions could be stored locally if needed.
  • Deprecates rx_controlEvents in favor of rx_controlEvent.

  • Deprecates MainScheduler.sharedInstance in favor of MainScheduler.instance

  • Deprecates ConcurrentMainScheduler.sharedInstance in favor of ConcurrentMainScheduler.instance

  • Deprecates factory methods from Drive in favor of Driver factory methods.

  • Deprecates sampleLatest in favor of withLatestFrom.

  • Deprecates ScopedDisposable and scopedDispose() in favor of DisposeBag.

Anomalies

  • Improves and documents resource leak code in RxExample.
  • Replaces unowned reference with weak references in RxCocoa project.
  • Fixes debug operator not using __FILE__ and __LINE__ properly.
  • Fixes anomaly with timeout operator.
  • Fixes problem with spell-checker and UIText* losing focus.

Check out Migration guide to RxSwift 2.0

Don't miss a new RxSwift release

NewReleases is sending notifications on new releases.