Browse Source

Added split combinator to actionObservable

master
Rohan Sircar 4 months ago
parent
commit
c59d48f6ec
1 changed files with 22 additions and 7 deletions
  1. +22
    -7
      src/main/scala/nova/monadic_sfx/implicits/ActionObservable.scala

+ 22
- 7
src/main/scala/nova/monadic_sfx/implicits/ActionObservable.scala View File

@ -1,6 +1,8 @@
package nova.monadic_sfx.implicits
import monix.execution.Cancelable
import monix.execution.Scheduler
import monix.execution.cancelables.CompositeCancelable
import monix.reactive.Observable
import monix.reactive.Observer
import monix.{eval => me}
@ -40,8 +42,7 @@ class ActionObservableBuilder[A](
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]) =
new ActionObservableExecutor[(B, C)](
@ -75,9 +76,23 @@ class ActionObservableBuilder[A](
)
.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