Added split combinator to actionObservable

This commit is contained in:
Rohan Sircar 2020-12-19 19:14:43 +05:30
parent 935ca358e6
commit c59d48f6ec

View File

@ -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]) = // Caution: Experimental stuff below..
// new ActionObservableBuilder(observableAction.publishSelector(f))
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 => def split(
// new ActionObservableBuilder[] 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[]) }