-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove overdue deprecations and remove observable value tracking (#274)
- Loading branch information
Showing
8 changed files
with
22 additions
and
254 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,25 @@ | ||
package colibri | ||
|
||
final class Connectable[+T] private (val value: T, val connect: () => Cancelable) { | ||
def map[A](f: T => A): Connectable[A] = new Connectable(f(value), connect) | ||
final class Connectable[+T] private (val value: T, val unsafeConnect: () => Cancelable) { | ||
def map[A](f: T => A): Connectable[A] = new Connectable(f(value), unsafeConnect) | ||
def flatMap[A](f: T => Connectable[A]): Connectable[A] = { | ||
val connectable = f(value) | ||
new Connectable(connectable.value, () => Cancelable.composite(connect(), connectable.connect())) | ||
new Connectable(connectable.value, () => Cancelable.composite(unsafeConnect(), connectable.unsafeConnect())) | ||
} | ||
} | ||
object Connectable { | ||
def apply[T](value: T, connect: () => Cancelable) = { | ||
val cancelable = Cancelable.refCount(connect) | ||
def apply[T](value: T, unsafeConnect: () => Cancelable) = { | ||
val cancelable = Cancelable.refCount(unsafeConnect) | ||
new Connectable(value, cancelable.ref) | ||
} | ||
|
||
@inline implicit class ConnectableObservableOperations[A](val source: Connectable[Observable[A]]) extends AnyVal { | ||
def refCount: Observable[A] = new Observable[A] { | ||
def unsafeSubscribe(sink: Observer[A]): Cancelable = Cancelable.composite(source.value.unsafeSubscribe(sink), source.connect()) | ||
def unsafeSubscribe(sink: Observer[A]): Cancelable = Cancelable.composite(source.value.unsafeSubscribe(sink), source.unsafeConnect()) | ||
} | ||
@deprecated("Use unsafeHot instead", "0.5.0") | ||
def hot: Observable.Hot[A] = unsafeHot() | ||
def unsafeHot(): Observable.Hot[A] = new Observable.Hot[A] { | ||
val cancelable = source.connect() | ||
def unsafeSubscribe(sink: Observer[A]): Cancelable = source.value.unsafeSubscribe(sink) | ||
} | ||
} | ||
|
||
@inline implicit class ConnectableObservableValueOperations[A](val source: Connectable[Observable.Value[A]]) extends AnyVal { | ||
def refCount: Observable.Value[A] = new Observable.Value[A] { | ||
def now() = source.value.now() | ||
def unsafeSubscribe(sink: Observer[A]): Cancelable = Cancelable.composite(source.value.unsafeSubscribe(sink), source.connect()) | ||
} | ||
@deprecated("Use unsafeHot instead", "0.7.8") | ||
def hot: Observable.HotValue[A] = unsafeHot() | ||
def unsafeHot(): Observable.HotValue[A] = new Observable.HotValue[A] { | ||
val cancelable = source.connect() | ||
def now() = source.value.now() | ||
def unsafeSubscribe(sink: Observer[A]): Cancelable = source.value.unsafeSubscribe(sink) | ||
} | ||
} | ||
|
||
@inline implicit class ConnectableObservableMaybeValueOperations[A](val source: Connectable[Observable.MaybeValue[A]]) extends AnyVal { | ||
def refCount: Observable.MaybeValue[A] = new Observable.MaybeValue[A] { | ||
def now() = source.value.now() | ||
def unsafeSubscribe(sink: Observer[A]): Cancelable = Cancelable.composite(source.value.unsafeSubscribe(sink), source.connect()) | ||
} | ||
@deprecated("Use unsafeHot instead", "0.7.8") | ||
def hot: Observable.HotMaybeValue[A] = unsafeHot() | ||
def unsafeHot(): Observable.HotMaybeValue[A] = new Observable.HotMaybeValue[A] { | ||
val cancelable = source.connect() | ||
def now() = source.value.now() | ||
def unsafeSubscribe(sink: Observer[A]): Cancelable = source.value.unsafeSubscribe(sink) | ||
def unsafeHot(): Observable[A] = { | ||
val _ = source.unsafeConnect() | ||
source.value | ||
} | ||
} | ||
} |
Oops, something went wrong.