I'm trying to get http4s going with monix, but running into this compiler error when trying to make some simple http routes
[error] Symbol 'type cats.effect.Effect' is missing from the classpath.
[error] This symbol is required by 'class monix.eval.instances.CatsEffectForTask'.
[error] Make sure that type Effect is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
[error] A full rebuild may help if 'CatsEffectForTask.class' was compiled against an incompatible version of cats.effect.
[error] val routes = HttpRoutes.of[Task] {
[error] ^
are there any known incompatibilities between monix and http4s? they're both on cats 2 afaik
Resource.eval(o.lastL)
or something on those lines and just live with the fact it's a bit crap
filter
step?case class
and if it is valid then send to the observer
val validatedMainItem = hdlMainItem
.filter { x =>
Inputs.validate(x) match {
case Valid(valid) =>
true
case Invalid(errors) =>
val err = errors.foldLeft(""){ case (acc, next) => acc + "\n" + next }.mkString("\n")
alert(err)
false
}
}.map { x =>
Inputs.validate(x) match {
case Valid(valid) => valid
case Invalid(error) => Inputs()
}
}
I mean perhaps in practice that's actually fine and does exactly what I need, and given that
Resource[F, T]
represents a singleT
, there's maybe not much else you can do
I wonder if there's potential for a subtype of Observable[T]
where the grammar is onNext? (onComplete | onError)?
, ie you'll get at most one T
. There's quite a few places in my code where I really want a "Task-with-cleanup", and either I have to use Resource
, which is clunky or Observable
which doesn't assert to consumers that there's only one element
Resource
instead :D
fromResource
relies on the backpressure after onNext
, so it's reliant on monix-specific divergence from Rx family of libraries in that internal protocol. It's a thing you can do, but it falls apart in some fairly innocuous scenarios and a lot of interop ones - and Alex argues having it is a mistake (see #1427)
hi, this is right?
val obsMainItem =
publishOnEventDocument
//.dump("En el obsMainItem ************")
.filter {
case Right(value@_) => true
case Left(err@_) => false
}
.map {
case Right((oldItem, newItem, event)) =>
event match {
case NotFoundDoobie(msg) => oldItem
case _ => newItem
}
case _ => ViewProcess() //Here never must be reach
}
The Left(err)
side is for another observable where I handle the errors.
val obsProcessSideEffects =
publishOnEventDocument
//.dump("Changos en el processSideEffects **************")
.map {
case Right((oldItem@_, newItem@_, event)) =>
event match {
case FoundDoobie(x) => div(x)
case SavedDoobie(x) => div(x)
case DeletedDoobie(x) => div(x)
case NotFoundDoobie(x) => div(x)
case ErrorDoobie(x) => div(x)
}
case Left(error) => error
}
The most up to date info can be found in Typevel discord, Alex is active there: https://discord.gg/hWd4eS244g
He answered a question about the CE3 roadmap recently:
Good question. I'm trying to come up with one and it is ... complicated, because it needs to have an identity that's different from Cats-Effect & fs2.
<br><br>
The value of Monix is in its pragmatism, its approach to FP that allows for impure interfaces to live alongside the pure ones (with established conventions), its deep integration with the host, its coherence, its fairly stable backwards compatibility.
<br><br>
Unfortunately, the task at hand on deciding what to do next, isn't easy to solve, and personally I've been away, on what people call an OSS hiatus. Trying to get back on that ride though.
<br><br>
In other news, in private I'm experimenting with a new Task. I have ideas and I'm foreseeing a philosophical divergence from cats.effect.IO. If CE evolves towards Task, the question would have been if Monix's implementation makes any sense, but CE 3 has actually moved further from Task's philosophy, and now I'm thinking Task can continue to provide value, while integrating CE3 ideas and also implement its type-classes.
<br><br>
Anyway, I was thinking of getting together with Monix contributors, discuss current issues, decide on a road-map, and call for help maybe, as there's plenty to work on.
<br><br>
This does mean that we are nowhere near a new major release. Sorry for not being able to give you a better answer.
uncancelable
and then in the doOnCancel
of the Task
somehow stopping further fetches, sending a Stop
signal upstream, but upstream from the processing part, as that needs to happen. Observable
.interval(1.seconds)
.flatMap(a => Observable.fromTask(Task.delay(println(a)).as(a))) // Fetching something from API, once fetched we need to ensure it is processed
.mapEval(a => Task.sleep(2.seconds).as(a))
.uncancelable
.consumeWith(Consumer.foreachParallelTask[Long](1)(a => Task.delay(println(s"arrived at the end $a")))) // This step always HAS to be invoked
.as(ExitCode.Success)
.doOnCancel(Task.sleep(10.seconds) *> Task.delay(println("CIAO")))
Hi, someone could tell me, please.
Why this code isn't working properly?
I want to request on different links, when the Observable
triggers an event.
val eventComparative = PublishSubject[String]()
val eventComparativePublish = eventComparative.publish
val cancelEventComparativePublish = eventComparativePublish.connect()
val getMinimosRetensionISR = eventComparativePublish.dump("0").mapEval { case idComparative => ...
val getProcess = eventComparativePublish.dump("0").mapEval { case idComparative => ...
val getComparativo = eventComparativePublish.dump("0").mapEval { case idComparative => ...
val observableZip3 = Observable.zip3(getMinimosRetensionISR, getProcess, getComparativo)
val cmdPrint = button("Imprimir", cls := "myButton",
SyncIO ( onClick.transformLifted { event: Observable[MouseEvent] =>
event
.withLatestFrom(getIdComparative) {
case (event@_, idComparative: String) =>
idComparative
}} --> repoCompara.eventComparative
)
)
PublishSubject
live: Repository
val publisher = PublishSubject[String]().publish
val cancelEventComparativePublish = publisher.connect()
val o1 = eventComparativePublish.dump("Event received!")
val publishTask = Observable.repeatEvalF(Task(eventComparative.onNext("Hi")))
Observable.zip2(o1, publishTask).completedL.runSyncUnsafe()