forked from ReactiveX/RxSwift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improves safety of binding code by tolerating binding from non main d…
…ispatch queue.
- Loading branch information
Showing
8 changed files
with
83 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../RxSwift/Platform/DispatchQueue+Extensions.swift |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../RxCocoa/Platform/DispatchQueue+Extensions.swift |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// UIBindingObserver+Tests.swift | ||
// Tests | ||
// | ||
// Created by Krunoslav Zaher on 12/17/16. | ||
// Copyright © 2016 Krunoslav Zaher. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import RxCocoa | ||
import XCTest | ||
import RxSwift | ||
|
||
class UIBindingObserverTests: RxTest { | ||
} | ||
|
||
extension UIBindingObserverTests { | ||
func testBindingOnNonMainQueueDispatchesToMainQueue() { | ||
let waitForElement = self.expectation(description: "wait until element arrives") | ||
let target = NSObject() | ||
let bindingObserver = UIBindingObserver<NSObject, Int>(UIElement: target) { (_, element: Int) in | ||
MainScheduler.ensureExecutingOnScheduler() | ||
waitForElement.fulfill() | ||
} | ||
|
||
DispatchQueue.global(qos: .default).async { | ||
bindingObserver.on(.next(1)) | ||
} | ||
|
||
self.waitForExpectations(timeout: 1.0) { (e) in | ||
XCTAssertNil(e) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters