import cats._
monix._
import monix._
outwatch.reactive.handler._
import outwatch.reactive.handler._
import cats.effect.ExitCode
import monix.execution.Scheduler
import monix.{eval => me}
import monix.bio._
import outwatch._
import outwatch.dsl._
import outwatch.reactive.handler._
import sttp.client3._
import sttp.client3.impl.monix.FetchMonixBackend
import sttp.capabilities.monix.MonixStreams
import java.util.concurrent.TimeUnit
import scala.concurrent.duration.Duration
val handlerTask = Handler.createF[monix.bio.Task, String]
without seed
mapEval
here:handler
.doOnNext(str => me.Task(println(str)))
.mapEval(query => request(query))
import cats.implicits._
Here are all of my imports just in case https://pastebin.com/3zm6eZTg
No way =( It compiles after addition of this:
def scheduler: Scheduler = Scheduler.global
def options: IO.Options = IO.defaultOptions.withSchedulerFeatures(scheduler)
implicit lazy val catsEffect: ConcurrentEffect[Task] =
new CatsConcurrentEffectForTask()(scheduler, options)
But nothing on the screen, unfortunately. Even no input field.
Hello there. I'm trying to get into outwatch. It seems to me that the docs are a bit outdated, what's the most recent/best source?
In particular, at the moment I want to get a simple example to work:
import cats.effect._
import outwatch._
import outwatch.dsl._
import outwatch.reactive.handler._
import outwatch.util._
import scala.concurrent.ExecutionContext.Implicits.global
object Main extends IOApp {
private val app = for {
hdl <- Handler.createF[IO]("")
qry <- IO.pure(hdl.map(query => Http.Request(s"https://someurl.org?query=$query")))
res <- IO(Http.get(qry).map(_.body))
xml <- IO.pure(div(
input(onInput.value --> hdl),
span(child <-- res)
))
rnd <- OutWatch.renderInto[IO]("#app", xml)
} yield rnd
override def run(args: List[String]): IO[ExitCode] =
app.as(ExitCode.Success)
}
but child
is not available. Am I missing an import? Or did something change? Thanks!
child <--
and just put the observable into the element directly: span(res)
Source
and a typeclass Sink
. You should be able to implement them with Stream
and Actor
respectively. Then you can use them in the outwatch dsl.
canvas(
managedElement { elem =>
val context = elem.asInstanceOf[dom.html.Canvas].getContext("2d").asInstanceOf[org.scalajs.dom.raw.CanvasRenderingContext2D]
// do something with context
cancelable(() => /*destroy something*/)
}
)