-
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.
- Loading branch information
Showing
14 changed files
with
349 additions
and
476 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
reactive/src/main/scala-2/colibri/reactive/LiveOwnerPlatform.scala
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,15 @@ | ||
package colibri.reactive | ||
|
||
import colibri.{Observable, Cancelable} | ||
|
||
trait LiveOwnerPlatform { | ||
@annotation.compileTimeOnly( | ||
"No implicit LiveOwner is available here! Wrap inside `Rx { <code> }`, or provide an implicit `LiveOwner`.", | ||
) | ||
implicit object compileTimeMock extends LiveOwner { | ||
def cancelable: Cancelable = ??? | ||
def unsafeNow[A](rx: Rx[A]): A = ??? | ||
def unsafeLive[A](rx: Rx[A]): A = ??? | ||
def liveObservable: Observable[Any] = ??? | ||
} | ||
} |
9 changes: 0 additions & 9 deletions
9
reactive/src/main/scala-2/colibri/reactive/OwnedPlatform.scala
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
reactive/src/main/scala-2/colibri/reactive/OwnerPlatform.scala
This file was deleted.
Oops, something went wrong.
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
2 changes: 0 additions & 2 deletions
2
...la-3/colibri/reactive/OwnerPlatform.scala → .../colibri/reactive/LiveOwnerPlatform.scala
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,5 +1,3 @@ | ||
package colibri.reactive | ||
|
||
trait OwnerPlatform | ||
|
||
trait LiveOwnerPlatform |
8 changes: 0 additions & 8 deletions
8
reactive/src/main/scala-3/colibri/reactive/OwnedPlatform.scala
This file was deleted.
Oops, something went wrong.
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,5 +1,5 @@ | ||
package colibri.reactive | ||
|
||
trait RxPlatform { | ||
def apply[R](f: LiveOwner ?=> R)(implicit owner: Owner): Rx[R] = Rx.function(implicit owner => f) | ||
def apply[R](f: LiveOwner ?=> R): Rx[R] = Rx.function(implicit owner => f) | ||
} |
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,36 @@ | ||
package colibri.reactive | ||
|
||
import colibri._ | ||
|
||
@annotation.implicitNotFound( | ||
"No implicit LiveOwner is available here! Wrap inside `Rx { <code> }`, or provide an implicit `LiveOwner`.", | ||
) | ||
trait LiveOwner { | ||
def liveObservable: Observable[Any] | ||
|
||
def unsafeLive[A](rx: Rx[A]): A | ||
def unsafeNow[A](rx: Rx[A]): A | ||
|
||
def cancelable: Cancelable | ||
} | ||
object LiveOwner extends LiveOwnerPlatform { | ||
def create(): LiveOwner = new LiveOwner { | ||
private val ref = Cancelable.builder() | ||
|
||
private val subject = Subject.publish[Any]() | ||
|
||
val cancelable: Cancelable = ref | ||
|
||
val liveObservable: Observable[Any] = subject | ||
|
||
def unsafeNow[A](rx: Rx[A]): A = { | ||
ref.unsafeAdd(() => rx.observable.unsafeSubscribe()) | ||
rx.nowGet() | ||
} | ||
|
||
def unsafeLive[A](rx: Rx[A]): A = { | ||
ref.unsafeAdd(() => rx.observable.to(subject).unsafeSubscribe()) | ||
rx.nowGet() | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.