Skip to content

Commit

Permalink
Replaces all calls to NopDisposable.instance with `Disposables.crea…
Browse files Browse the repository at this point in the history
…te()`.
  • Loading branch information
mohsenr committed Aug 10, 2016
1 parent a981d4c commit 1fe15bb
Show file tree
Hide file tree
Showing 52 changed files with 136 additions and 136 deletions.
4 changes: 2 additions & 2 deletions Documentation/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ func myJust<E>(element: E) -> Observable<E> {
return Observable.create { observer in
observer.on(.Next(element))
observer.on(.Completed)
return NopDisposable.instance
return Disposables.create()
}
}

Expand Down Expand Up @@ -329,7 +329,7 @@ func myFrom<E>(sequence: [E]) -> Observable<E> {
}

observer.on(.Completed)
return NopDisposable.instance
return Disposables.create()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ example("create") {
return Observable.create { observer in
observer.on(.next(element))
observer.on(.completed)
return NopDisposable.instance
return Disposables.create()
}
}

Expand Down Expand Up @@ -170,7 +170,7 @@ example("deferred") {
observer.onNext("🐶")
observer.onNext("🐱")
observer.onNext("🐵")
return NopDisposable.instance
return Disposables.create()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ example("debug") {
observer.onNext("🐭")
observer.onCompleted()

return NopDisposable.instance
return Disposables.create()
}

sequenceThatErrors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ example("retry") {
observer.onNext("🐭")
observer.onCompleted()

return NopDisposable.instance
return Disposables.create()
}

sequenceThatErrors
Expand Down Expand Up @@ -119,7 +119,7 @@ example("retry maxAttemptCount") {
observer.onNext("🐭")
observer.onCompleted()

return NopDisposable.instance
return Disposables.create()
}

sequenceThatErrors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ example("Observable with no subscribers") {
print("This will never be printed")
observerOfString.on(.next("😬"))
observerOfString.on(.completed)
return NopDisposable.instance
return Disposables.create()
}
}
/*:
Expand All @@ -70,7 +70,7 @@ example("Observable with subscriber") {
print("Observable created")
observerOfString.on(.next("😉"))
observerOfString.on(.completed)
return NopDisposable.instance
return Disposables.create()
}
.subscribe { event in
print(event)
Expand Down
2 changes: 1 addition & 1 deletion RxBlocking/RunLoopLock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class RunLoopLock {
if CurrentThreadScheduler.isScheduleRequired {
_ = CurrentThreadScheduler.instance.schedule(()) { _ in
action()
return NopDisposable.instance
return Disposables.create()
}
}
else {
Expand Down
4 changes: 2 additions & 2 deletions RxCocoa/OSX/NSControl+Rx.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extension NSControl {

guard let control = self else {
observer.on(.completed)
return NopDisposable.instance
return Disposables.create()
}

let observer = ControlTarget(control: control) { control in
Expand All @@ -54,7 +54,7 @@ extension NSControl {
return Observable.create { [weak weakControl = control] (observer: AnyObserver<T>) in
guard let control = weakControl else {
observer.on(.completed)
return NopDisposable.instance
return Disposables.create()
}

observer.on(.next(getter(control)))
Expand Down
2 changes: 1 addition & 1 deletion RxCocoa/iOS/UIBarButtonItem+Rx.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extension UIBarButtonItem {
Observable.create { [weak self] observer in
guard let control = self else {
observer.on(.completed)
return NopDisposable.instance
return Disposables.create()
}
let target = BarButtonItemTarget(barButtonItem: control) {
observer.on(.next())
Expand Down
4 changes: 2 additions & 2 deletions RxCocoa/iOS/UIControl+Rx.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ extension UIControl {

guard let control = self else {
observer.on(.completed)
return NopDisposable.instance
return Disposables.create()
}

let controlTarget = ControlTarget(control: control, controlEvents: controlEvents) {
Expand All @@ -67,7 +67,7 @@ extension UIControl {
let source: Observable<T> = Observable.create { [weak weakControl = control] observer in
guard let control = weakControl else {
observer.on(.completed)
return NopDisposable.instance
return Disposables.create()
}

observer.on(.next(getter(control)))
Expand Down
2 changes: 1 addition & 1 deletion RxCocoa/iOS/UIGestureRecognizer+Rx.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ extension Reactive where Self: UIGestureRecognizer {

guard let control = self else {
observer.on(.completed)
return NopDisposable.instance
return Disposables.create()
}

let observer = GestureTarget(control) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ extension TestScheduler {
let scheduledEvents = events[attemptCount].map { event in
return self.scheduleRelative((), dueTime: resolution * TimeInterval(event.time)) { _ in
observer.on(event.value)
return NopDisposable.instance
return Disposables.create()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ extension UIImagePickerController {
}
catch let error {
observer.on(.error(error))
return NopDisposable.instance
return Disposables.create()
}

guard let parent = parent else {
observer.on(.completed)
return NopDisposable.instance
return Disposables.create()
}

parent.present(imagePicker, animated: animated, completion: nil)
Expand Down
2 changes: 1 addition & 1 deletion RxSwift/Disposables/RefCountDisposable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public final class RefCountDisposable : DisposeBase, Cancelable {

return RefCountInnerDisposable(self)
} else {
return NopDisposable.instance
return Disposables.create()
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion RxSwift/Disposables/ScheduledDisposable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation

private let disposeScheduledDisposable: (ScheduledDisposable) -> Disposable = { sd in
sd.disposeInner()
return NopDisposable.instance
return Disposables.create()
}

/**
Expand Down
2 changes: 1 addition & 1 deletion RxSwift/Disposables/SingleAssignmentDisposable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class SingleAssignmentDisposable : DisposeBase, Disposable, Cancelable {
public var disposable: Disposable {
get {
_lock.lock(); defer { _lock.unlock() }
return _disposable ?? NopDisposable.instance
return _disposable ?? Disposables.create()
}
set {
_setDisposable(newValue)?.dispose()
Expand Down
4 changes: 2 additions & 2 deletions RxSwift/ObservableType+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ extension ObservableType {
disposable = AnonymousDisposable(disposed)
}
else {
disposable = NopDisposable.instance
disposable = Disposables.create()
}

let observer = AnonymousObserver<E> { e in
Expand Down Expand Up @@ -91,7 +91,7 @@ extension ObservableType {
disposable = AnonymousDisposable(disposed)
}
else {
disposable = NopDisposable.instance
disposable = Disposables.create()
}

let observer = AnonymousObserver<E> { e in
Expand Down
2 changes: 1 addition & 1 deletion RxSwift/Observables/Implementations/Buffer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class BufferTimeCountSink<Element, O: ObserverType where O.E == [Element]>
self.startNewWindowAndSendCurrentOne()
}

return NopDisposable.instance
return Disposables.create()
}
}
}
2 changes: 1 addition & 1 deletion RxSwift/Observables/Implementations/Deferred.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class DeferredSink<S: ObservableType, O: ObserverType where S.E == O.E> : Sink<O
catch let e {
forwardOn(.error(e))
dispose()
return NopDisposable.instance
return Disposables.create()
}
}

Expand Down
2 changes: 1 addition & 1 deletion RxSwift/Observables/Implementations/Empty.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ import Foundation
class Empty<Element> : Producer<Element> {
override func subscribe<O : ObserverType where O.E == Element>(_ observer: O) -> Disposable {
observer.on(.completed)
return NopDisposable.instance
return Disposables.create()
}
}
2 changes: 1 addition & 1 deletion RxSwift/Observables/Implementations/Error.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ class Error<Element> : Producer<Element> {

override func subscribe<O : ObserverType where O.E == Element>(_ observer: O) -> Disposable {
observer.on(.error(_error))
return NopDisposable.instance
return Disposables.create()
}
}
4 changes: 2 additions & 2 deletions RxSwift/Observables/Implementations/Just.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class JustScheduledSink<O: ObserverType> : Sink<O> {
self.forwardOn(.next(element))
return scheduler.schedule(()) { _ in
self.forwardOn(.completed)
return NopDisposable.instance
return Disposables.create()
}
}
}
Expand Down Expand Up @@ -56,6 +56,6 @@ class Just<Element> : Producer<Element> {
override func subscribe<O : ObserverType where O.E == Element>(_ observer: O) -> Disposable {
observer.on(.next(_element))
observer.on(.completed)
return NopDisposable.instance
return Disposables.create()
}
}
2 changes: 1 addition & 1 deletion RxSwift/Observables/Implementations/Multicast.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class MulticastSink<S: SubjectType, O: ObserverType>: Sink<O>, ObserverType {
catch let e {
forwardOn(.error(e))
dispose()
return NopDisposable.instance
return Disposables.create()
}
}

Expand Down
2 changes: 1 addition & 1 deletion RxSwift/Observables/Implementations/Never.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ import Foundation

class Never<Element> : Producer<Element> {
override func subscribe<O : ObserverType where O.E == Element>(_ observer: O) -> Disposable {
return NopDisposable.instance
return Disposables.create()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ObserveOnSerialDispatchQueueSink<O: ObserverType> : ObserverBase<O.E> {
sink.dispose()
}

return NopDisposable.instance
return Disposables.create()
}
}

Expand Down
2 changes: 1 addition & 1 deletion RxSwift/Observables/Implementations/ShareReplay1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ final class ShareReplay1<Element>

if let stopEvent = self._stopEvent {
observer.on(stopEvent)
return NopDisposable.instance
return Disposables.create()
}

let initialCount = self._observers.count
Expand Down
2 changes: 1 addition & 1 deletion RxSwift/Observables/Implementations/Skip.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class SkipTimeSink<ElementType, O: ObserverType where O.E == ElementType> : Sink
func run() -> Disposable {
let disposeTimer = parent.scheduler.scheduleRelative((), dueTime: self.parent.duration) {
self.tick()
return NopDisposable.instance
return Disposables.create()
}

let disposeSubscription = parent.source.subscribe(self)
Expand Down
2 changes: 1 addition & 1 deletion RxSwift/Observables/Implementations/SubscribeOn.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class SubscribeOnSink<Ob: ObservableType, O: ObserverType where Ob.E == O.E> : S
cancelSchedule.disposable = parent.scheduler.schedule(()) { (_) -> Disposable in
let subscription = self.parent.source.subscribe(self)
disposeEverything.disposable = ScheduledDisposable(scheduler: self.parent.scheduler, disposable: subscription)
return NopDisposable.instance
return Disposables.create()
}

return disposeEverything
Expand Down
2 changes: 1 addition & 1 deletion RxSwift/Observables/Implementations/Take.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class TakeTimeSink<ElementType, O: ObserverType where O.E == ElementType>
func run() -> Disposable {
let disposeTimer = _parent._scheduler.scheduleRelative((), dueTime: _parent._duration) {
self.tick()
return NopDisposable.instance
return Disposables.create()
}

let disposeSubscription = _parent._source.subscribe(self)
Expand Down
2 changes: 1 addition & 1 deletion RxSwift/Observables/Implementations/Throttle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class ThrottleSink<O: ObserverType>
forwardOn(.next(value))
}
// }
return NopDisposable.instance
return Disposables.create()
}
}

Expand Down
2 changes: 1 addition & 1 deletion RxSwift/Observables/Implementations/Timeout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class TimeoutSink<ElementType, O: ObserverType where O.E == ElementType>: Sink<O
self._subscription.disposable = self._parent._other.subscribeSafe(self.forwarder())
}

return NopDisposable.instance
return Disposables.create()
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion RxSwift/Observables/Implementations/Timer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class TimerOneOffSink<O: ObserverType where O.E : SignedInteger> : Sink<O> {
self.forwardOn(.next(0))
self.forwardOn(.completed)

return NopDisposable.instance
return Disposables.create()
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion RxSwift/Observables/Implementations/Using.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class UsingSink<SourceType, ResourceType: Disposable, O: ObserverType where O.E
}

func run() -> Disposable {
var disposable = NopDisposable.instance
var disposable = Disposables.create()

do {
let resource = try _parent._resourceFactory()
Expand Down
2 changes: 1 addition & 1 deletion RxSwift/Observables/Implementations/Window.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class WindowTimeCountSink<Element, O: ObserverType where O.E == Observable<Eleme

self.createTimer(newId)

return NopDisposable.instance
return Disposables.create()
}
}
}
Expand Down
Loading

0 comments on commit 1fe15bb

Please sign in to comment.