Releases: ReactiveX/RxSwift
on(.Next("2.0.0"))
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.
- use cases like
- Linux support (proof of concept, but single threaded mode works)
- more info in Documentation/Linux.md
- Initial support for
Swift Package Manager- works on
Linux(RxSwift,RxBlocking,RxTests) - doesn't work on OSX because it can't compile
RxCocoaandRxTests(because of inclusion ofXCTestextensions), but OSX has two other package managers and manual method. - Project content is linked to
Sourcesautomagically using custom tool - more info in Documentation/Linux.md
- works on
- Adds
VirtualTimeSchedulertoRxSwift - Adds
HistoricalSchedulertoRxSwift - Improves performance of virtual schedulers using priority queue.
- Adds new
RxTestslibrary 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-iOSthat demonstrates how to easily write marble tests usingRxTestsproject.
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
DriverinUnits.md. - Example of table view with editing is polished to use more functional approach.
- Adds
deferredtoDriverunit. - Removes implicitly unwrapped optionals from
CLLocationManagerextensions. - Removes implicitly unwrapped optionals from
NSURLSessionextensions. - Polishes the
debugoperator format. - Adds optional
cellTypeparameter to Table/Collection viewrx_itemsWithCellIdentifiermethod. - Polish for calculator example in
RxExampleapp. - Documents and adds unit tests for tail recursive optimizations of
concatoperator. - Moves
Eventequality operator toRxTestsproject. - Adds
seealsoreferences toreactivex.io. - Polishes headers in source files and adds tests to enforce standard header format.
- Adds
driveOnSchedulerto enable scheduler mocking forDriverduring 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
RxBoxandRxMutablebox from public interface. (BREAKING CHANGE) -
SchedulerTypenow isn't parametrized onTimeandTimeInterval. -
Deprecates
VariableimplementingObservableTypein favor ofasObservable().- Now variable also sends
.Completedto observable sequence returned fromasObservablewhen deallocated.
If you were (mis)using variable to return single value
Variable(1).map { x in ... }
... you can just usejustoperator
Observable.just(1).map { x in ... }
- Now variable also sends
-
Deprecates free functions in favor of
Observablefactory 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 ofjust(1)Observable.empty()instead ofempty()Observable.error()instead offailWith()Observable.of(1, 2, 3)instead ofsequenceOf(1, 2, 3).debounce(0.2, scheduler: MainScheduler.sharedInstance)instead of.debounce(0.2, MainScheduler.sharedInstance)Observable.range(start:0, count: 10)instead ofrange(0, 10)Observable.generate(initialState: 0, condition: { $0 < 10 }) { $0 + 1 }instead ofgenerate(0, condition: { $0 < 10 }) { $0 + 1 }Observable<Int>.interval(1, scheduler: MainScheduler.sharedInstance)instead ofinterval(1, MainScheduler.sharedInstance)...
If you want to continue using free functions form, you can define your free function aliases for
Observablefactory methods (basically copy deprecated methods). -
Deprecates
UIAlertViewextensions.- These extensions could be stored locally if needed.
-
Deprecates
UIActionSheetextensions.- These extensions could be stored locally if needed.
-
Deprecates
rx_controlEventsin favor ofrx_controlEvent. -
Deprecates
MainScheduler.sharedInstancein favor ofMainScheduler.instance -
Deprecates
ConcurrentMainScheduler.sharedInstancein favor ofConcurrentMainScheduler.instance -
Deprecates factory methods from
Drivein favor ofDriverfactory methods. -
Deprecates
sampleLatestin favor ofwithLatestFrom. -
Deprecates
ScopedDisposableandscopedDispose()in favor ofDisposeBag.
Anomalies
- Improves and documents resource leak code in
RxExample. - Replaces
unownedreference withweakreferences inRxCocoaproject. - Fixes
debugoperator not using__FILE__and__LINE__properly. - Fixes anomaly with
timeoutoperator. - Fixes problem with spell-checker and
UIText*losing focus.
Check out Migration guide to RxSwift 2.0
Type.self
This is a beta version of RxSwift 2.0.
This is last beta version. Next release will be first RC.
Updated
- Adds
ignoreElementsoperator. - Adds
timeoutoperator (2 overloads). - Adds
shareReplayLatestWhileConnectedoperator. - Changes
Driverto internally useshareReplayLatestWhileConnectedfor subscription sharing instead ofshareReplay(1). - Adds
flatMapFirsttoDriverunit. - Adds
replayAlloperator. - Adds
createUnboundedfactory method toReplaySubject. - Adds optional type hints to
empty,failWithandnever(empty(Int)now works and means empty observable sequence ofInts). - Adds
rx_hiddentoUIView. - Adds
rx_alphatoUIView. - Adds
rx_attributedTexttoUILabel. - Adds
rx_animatingtoUIActivityIndicatorView. - Adds
rx_constanttoNSLayoutConstraint. - Removes implicitly unwrapped optional from
NSURLSession.rx_response. - Exposes
rx_createDataSourceProxy,rx_createDelegateProxyonUITableView/UICollectionView. - Exposes
rx_createDelegateProxyonUITextView. - Exposes
rx_createDelegateProxyonUIScrollView. - Exposes
RxCollectionViewDataSourceProxy. - Exposes
RxCollectionViewDelegateProxy. - Exposes
RxScrollViewDelegateProxy. - Exposes
RxTableViewDataSourceProxy. - Exposes
RxTableViewDelegateProxy. - Deprecates
proxyForObjectin favor ofproxyForObject<P : DelegateProxyType>(type: P.Type, _ object: AnyObject) -> P. - Deprecates
rx_modelSelected<T>()in favor ofrx_modelSelected<T>(modelType: T.Type). - Adds
func bindTo(variable: Variable<E>) -> Disposableextension toObservableType. - Exposes
ControlEventinit. - Exposes
ControlPropertyinit. - Refactoring of example app
- Divides examples into sections
- Adds really simple examples of how to do simple calculated bindings with vanilla Rx.
- Adds really simple examples of table view extensions (sectioned and non sectioned version).
- Refactoring of
GitHub sign in exampleto use MVVM paradigm.
Fixed
- Fixes documentation for
flatMapFirst - Fixes problem with delegate proxies not detecting all delegate methods in delegate proxy hierarchy.
Check out Migration guide to RxSwift 2.0
The art of state
This is a beta version of RxSwift 2.0.
Updated
- Improves KVO mechanism.
- Type of observed object is now first argument
view.rx_observe(CGRect.self, "frame") - Support for observing ObjC bridged enums and
RawRepresentableprotocol - Support for easier extending of KVO using
KVORepresentableprotocol - Deprecates KVO extensions that don't accept type as first argument in favor of ones that do.
- Type of observed object is now first argument
- Adds
flatMapLatest(also added toDriverunit). - Adds
flatMapFirstoperator (also added toDriverunit). - Adds
retryWhenoperator. - Adds
windowoperator. - Adds
singleoperator. - Adds
single(blocking version) operator. - Adds
rx_primaryActiononUIButtonfortvOS. - Transforms error types in
RxSwift/RxCocoaprojects fromNSErrors to Swift enum types.RxErrorRxCocoaErrorRxCocoaURLError- ...
NSURLSessionextensions now returnObservable<(NSData!, NSHTTPURLResponse)>instead ofObservable<(NSData!, NSURLResponse!)>.- Optimizes consecutive map operators. For example
map(validate1).map(validate2).map(parse)is now internally optimized to onemapoperator. - Adds overloads for
just,sequenceOf,toObservablethat accept scheduler. - Deprecates
asObservableextension ofSequenceTypein favor oftoObservable. - Adds
toObservableextension toArray. - Improves table view animated data source example.
- Polishing of
RxDataSourceStarterKitdifferentiateForSectionedViewoperatorrx_itemsAnimatedWithDataSourceextension
- Makes blocking operators run current thread's runloop while blocking and thus disabling deadlocks.
Fixed
- Fixes example with
Variablein playgrounds so it less confusing regarding memory management. - Fixes
UIImageViewextensions to useUIImage?instead ofUIImage!. - Fixes improper usage of
CustomStringConvertibleand replaces it withCustomDebugStringConvertible.
Check out Migration guide to RxSwift 2.0
Heapster
This is a beta version of RxSwift 2.0.
Updated
- Optimizations. System now performs significantly fewer allocations and is several times faster then 2.0.0-beta.1
- Makes
AnonymousObservableprivate in favor ofcreatemethod. - Adds
toArrayoperator (non blocking version). - Adds
withLatestFromoperator, and also extendsDriverwith that operation. - Adds
elementAtoperator (non blocking version). - Adds
takeLastoperator. - Improves
RxExampleapp. Adds retries example when network becomes available again. - Adds composite extensions to
Bag(on,disposeAllIn). - Renames mistyped extension on
ObserverTypefromonCompletetoonCompleted.
Fixed
- Fixes minimal platform version in OSX version of library to 10.9
Check out Migration guide to RxSwift 2.0
Juraj
This is a beta version of RxSwift 2.0.
Updated
- Adds
Driverunit. This unit uses Swift compiler to prove certain properties about observable sequences. Specifically- that fallback error handling is put in place
- results are observed on main thread
- work is performed only when there is a need (at least one subscriber)
- computation results are shared between different observers (replay latest element)
- Renames
ObserverOftoAnyObserver. - Adds new interface
ObservableConvertibleType. - Adds
BlockingObservabletoRxBlockingand makes it more consistent withRxJava. - Renames
func subscribe(next:error:completed:disposed:)tofunc subscribe(onNext:onError:onCompleted:onDisposed:) - Adds concat convenience method
public func concat<O : ObservableConvertibleType where O.E == E>(second: O) -> RxSwift.Observable<Self.E> - Adds
skipUntiloperator. - Adds
takeWhileoperator. - Renames
takeWhileindexed version totakeWhileWithIndex - Adds
skipWhileoperator. - Adds
skipWhileWithIndexoperator. - Adds
usingoperator. - Renames
func doOn(next:error:completed:)tofunc doOn(onNext:onError:onCompleted:). - Makes
RecursiveImmediateSchedulerOfprivate. - Makes
RecursiveSchedulerOfprivate. - Adds
ConcurrentMainScheduler. - Adds overflow error so now in case of overflow, operators will return
RxErrorCode.Overflow. - Adds
rx_modelAtIndexPathtoUITableViewandUICollectionView. - Adds
var rx_didUpdateFocusInContextWithAnimationCoordinator: ControlEvent<(context:animationCoordinator:)>toUITableViewandUICollectionView - Makes
resultSelectorargument incombineLatestexplicitfunc combineLatest<O1, O2, R>(source1: O1, _ source2: O2, resultSelector: (O1.E, O2.E) throws -> R) -> RxSwift.Observable<R>. - Makes
resultSelectorargument inzipexplicitfunc combineLatest<O1, O2, R>(source1: O1, _ source2: O2, resultSelector: (O1.E, O2.E) throws -> R) -> RxSwift.Observable<R>. - Adds activity indicator example in
RxExampleapp. - Adds two way binding example in
RxExampleapp. - many other small features
Fixed
- Problem with xcodebuild 7.0.1 treating tvOS shared schemes as osx schemes.
Check out Migration guide to RxSwift 2.0
Screenzilla
This is a alpha version of RxSwift 2.0.
Updated
- Adds
tvOSsupport - Adds
watchOSsupport - Adds auto loading example to example app
- Restores old
Variablebehavior. Variable doesn't send anything on dealloc. - Adds performance tests target.
- Adds more detailed resource tracing during unit tests (important for further optimizations).
- Adds
UIStepperextensions. - Adds
UIBarButtonItemenabled property wrapper. - Adds response data to userInfo of error for
rx_responseextensions ofNSURLSession. - Adds
onNext,onErrorandonCompletedconvenience methods toObserverType.
Fixed
- Fixes problem on some systems with unregistering
CurrentThreadSchedulerfrom current thread. - Fixes retry parameter naming (
maxAttemptCount). - Fixes a lot of unit test warnings.
- Removes embedding of Swift library with built frameworks.
Check out Migration guide to RxSwift 2.0
Anamorphism
This is a alpha version of RxSwift 2.0.
- Renames
ImmediateSchedulerprotocol toImmediateSchedulerType - Renames
Schedulerprotocol toSchedulerType - Adds
CurrentThreadScheduler - Adds
generateoperator - Cleanup of dead observer code.
- Removes
SpinLocks in disposables in favor of more performantOSAtomicCompareAndSwap32. - Adds
bufferoperator (version with time and count). - Adds
rangeoperator. - Adds
repeatoperator.
Check out Migration guide to RxSwift 2.0
l3O
This is a alpha version of RxSwift 2.0.
- Renames
ScopedDisposetoScopedDisposable - Deprecates
observeSingleOnin favor ofobserveOn - Adds inline documentation
- Renames
fromtoasObservableextension method onSequenceType - Renames
catchErrorResumeNextin favor ofcatchErrorJustReturn - Deprecates
catchErrorToResult, the preferred way is to use Swiftdo/try/catchmechanism. - Deprecates
RxResult, the preferred way is to use Swiftdo/try/catchmechanism. - Deprecates
sendNextonVariablein favor of just usingvaluesetter. - Renames
rx_searchTexttorx_textonUISearchBar+Rx. - Changes parameter type for
rx_imageAnimatedto be transitionType (kCATransitionFade, kCATransitionMoveIn, ...).
Check out Migration guide to RxSwift 2.0
NS
This is a alpha version of RxSwift 2.0.
New version of the language helped us to improve a lot of things and this is a short summary of changes.
- Removes deprecated APIs
- Adds
ObservableType - Moved from using
>-operator to protocol extensions. - Adds support for Swift 2.0 error handling
try/do/catch
You can now just write
API.fetchData(URL)
.map { rawData in
if invalidData(rawData) {
throw myParsingError
}
...
return parsedData
}- RxCocoa introduces
bindToextensions
combineLatest(firstName.rx_text, lastName.rx_text) { $0 + " " + $1 }
.map { "Greeting \($0)" }
.bindTo(greetingLabel.rx_text)... works for UITableView/UICollectionView too
viewModel.rows
.bindTo(resultsTableView.rx_itemsWithCellIdentifier("WikipediaSearchCell")) { (_, viewModel, cell: WikipediaSearchCell) in
cell.viewModel = viewModel
}
.addDisposableTo(disposeBag)- Adds new operators (array version of
zip, array version ofcombineLatest, ...) - Renames
catchtocatchError - Change from
disposeBag.addDisposabletodisposable.addDisposableTo - Deprecates
aggregatein favor ofreduce - Deprecates
variablein favor ofshareReplay(1)(to be consistent with RxJS version)
Check out Migration guide to RxSwift 2.0