Skip to content

Commit

Permalink
add Var.none/some/subjectSync
Browse files Browse the repository at this point in the history
  • Loading branch information
cornerman committed Jan 9, 2023
1 parent 29e1ffe commit 5dba05e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions reactive/src/main/scala/colibri/reactive/Reactive.scala
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ trait Var[A] extends RxWriter[A] with Rx[A] {
object Var {
def apply[A](seed: A): Var[A] = new VarSubject(seed)

def none[A](): Var[Option[A]] = new VarSubject(None)
def some[A](seed: A): Var[Option[A]] = new VarSubject(Some(seed))

def subjectSync[A](read: Subject[A]): Var[A] = combine(Rx.observableSync(read), RxWriter.observer(read))

def combine[A](read: Rx[A], write: RxWriter[A]): Var[A] = new VarCombine(read, write)

@inline implicit class SeqVarOperations[A](rxvar: Var[Seq[A]]) {
Expand Down

0 comments on commit 5dba05e

Please sign in to comment.