Browse Source

Added split combinator to actionObservable

master
Rohan Sircar 3 years ago
parent
commit
c59d48f6ec
  1. 29
      src/main/scala/nova/monadic_sfx/implicits/ActionObservable.scala

29
src/main/scala/nova/monadic_sfx/implicits/ActionObservable.scala

@ -1,6 +1,8 @@
package nova.monadic_sfx.implicits package nova.monadic_sfx.implicits
import monix.execution.Cancelable
import monix.execution.Scheduler import monix.execution.Scheduler
import monix.execution.cancelables.CompositeCancelable
import monix.reactive.Observable import monix.reactive.Observable
import monix.reactive.Observer import monix.reactive.Observer
import monix.{eval => me} import monix.{eval => me}
@ -40,8 +42,7 @@ class ActionObservableBuilder[A](
def underlying = observableAction def underlying = observableAction
// def publish[B](f: Observable[A] => Observable[B]) =
// new ActionObservableBuilder(observableAction.publishSelector(f))
// Caution: Experimental stuff below..
def useEval2[B, C](f: A => me.Task[B], g: A => me.Task[C]) = def useEval2[B, C](f: A => me.Task[B], g: A => me.Task[C]) =
new ActionObservableExecutor[(B, C)]( new ActionObservableExecutor[(B, C)](
@ -75,9 +76,23 @@ class ActionObservableBuilder[A](
) )
.subscribe() .subscribe()
// def useEval2[B,C](a1: ActionObservableBuilder[A] => B, a2: ActionObservableBuilder[A] => C) = observableAction.publishSelector(conn =>
// new ActionObservableBuilder[]
// )
}
def split(
lst: (ActionObservableBuilder[A] => Cancelable)*
)(implicit s: Scheduler): Cancelable = {
val comp = CompositeCancelable()
comp += observableAction
.publishSelector(conn =>
Observable(
lst.map(f =>
Observable.unit.doOnNext(_ =>
me.Task(
comp += f(new ActionObservableBuilder[A](conn))
) >> me.Task.unit
)
): _*
).merge
)
.subscribe()
}
// class MappedActionExecutor(actionMap: Map[])
}
Loading…
Cancel
Save