Skip to content

Commit 81fd380

Browse files
committed
Moves bind(to:) to Variable to Deprecated.
1 parent f639ff4 commit 81fd380

File tree

2 files changed

+40
-40
lines changed

2 files changed

+40
-40
lines changed

RxCocoa/Common/Observable+Bind.swift

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -38,46 +38,6 @@ extension ObservableType {
3838
return self.map { $0 }.subscribe(observer)
3939
}
4040

41-
/**
42-
Creates new subscription and sends elements to variable.
43-
44-
In case error occurs in debug mode, `fatalError` will be raised.
45-
In case error occurs in release mode, `error` will be logged.
46-
47-
- parameter to: Target variable for sequence elements.
48-
- returns: Disposable object that can be used to unsubscribe the observer.
49-
*/
50-
public func bind(to variable: Variable<E>) -> Disposable {
51-
return subscribe { e in
52-
switch e {
53-
case let .next(element):
54-
variable.value = element
55-
case let .error(error):
56-
let error = "Binding error to variable: \(error)"
57-
#if DEBUG
58-
rxFatalError(error)
59-
#else
60-
print(error)
61-
#endif
62-
case .completed:
63-
break
64-
}
65-
}
66-
}
67-
68-
/**
69-
Creates new subscription and sends elements to variable.
70-
71-
In case error occurs in debug mode, `fatalError` will be raised.
72-
In case error occurs in release mode, `error` will be logged.
73-
74-
- parameter to: Target variable for sequence elements.
75-
- returns: Disposable object that can be used to unsubscribe the observer.
76-
*/
77-
public func bind(to variable: Variable<E?>) -> Disposable {
78-
return self.map { $0 as E? }.bind(to: variable)
79-
}
80-
8141
/**
8242
Subscribes to observable sequence using custom binder function.
8343

RxCocoa/Deprecated.swift

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,46 @@ extension SharedSequenceConvertibleType where SharingStrategy == DriverSharingSt
449449
}
450450
}
451451

452+
extension ObservableType {
453+
/**
454+
Creates new subscription and sends elements to variable.
452455

456+
In case error occurs in debug mode, `fatalError` will be raised.
457+
In case error occurs in release mode, `error` will be logged.
458+
459+
- parameter to: Target variable for sequence elements.
460+
- returns: Disposable object that can be used to unsubscribe the observer.
461+
*/
462+
public func bind(to variable: Variable<E>) -> Disposable {
463+
return subscribe { e in
464+
switch e {
465+
case let .next(element):
466+
variable.value = element
467+
case let .error(error):
468+
let error = "Binding error to variable: \(error)"
469+
#if DEBUG
470+
rxFatalError(error)
471+
#else
472+
print(error)
473+
#endif
474+
case .completed:
475+
break
476+
}
477+
}
478+
}
479+
480+
/**
481+
Creates new subscription and sends elements to variable.
482+
483+
In case error occurs in debug mode, `fatalError` will be raised.
484+
In case error occurs in release mode, `error` will be logged.
485+
486+
- parameter to: Target variable for sequence elements.
487+
- returns: Disposable object that can be used to unsubscribe the observer.
488+
*/
489+
public func bind(to variable: Variable<E?>) -> Disposable {
490+
return self.map { $0 as E? }.bind(to: variable)
491+
}
492+
}
453493

454494

0 commit comments

Comments
 (0)