Questions tagged [monix]

Monix is a library providing asynchronous programming facilities for Scala and Scala.js.

94 questions
0
votes
1 answer

Task[List[List[A]]] to Task[A] if list has elements

I have a method which returns Task[List[List[A]]] and I need to transform to Task[A] if the list is greater than 0 def method():Task[List[List[A]]] = {} val d:Task[List[A]] = method().map(_.flatten) How to get Task[A] is a list of A if the inner…
Sumeet Kumar Yadav
  • 11,912
  • 6
  • 43
  • 80
0
votes
1 answer

Collecting data from all tasks executed on monix Scheduler

I'm using Monix Scheduler to execute some tasks periodically. But I don't know how to not just execute them, but also to collect result from them to some collection... Lets say I have a scheduled task that returns a random number every time: val…
Lykov
  • 5
  • 1
0
votes
1 answer

How to buffer emission with custom weither function

I need functionality like monix.Observable.bufferTimedAndCounted but with custom "weither". I found bufferTimedWithPressure operator which allow use item's weith: val subj = PublishSubject[String]() subj .bufferTimedWithPressure(1.seconds, 5, _…
zella
  • 4,645
  • 6
  • 35
  • 60
0
votes
1 answer

Monix write to single output stream from parallel Tasks

how can we use Monix Tasks to write a single output stream from a sequence of tasks (can run in parallel): for example, I have N tasks that can be run in parallel and get some response from HTTP call/server, and I'm writing the response back to a…
vkt
  • 1,401
  • 2
  • 20
  • 46
0
votes
0 answers

how to implement back-pressure for a reactive network library?

There is a little long background story about the problem in my socket reactive library working process. The socket library mainly based on a reactive library named Monix(similar ReactiveX). Monix has the best practice to handle back-pressure by…
LoranceChen
  • 2,453
  • 2
  • 22
  • 48
0
votes
1 answer

empty in Monix Task

Project Reactor has something like Mono.empty[T]() which can be handled in special circumstances where you do not have anything when it is evaluated. Is there something similar in Monix Task? def getItemFromList[T](inp: Mono[List[T]]): Mono[T] = { …
0
votes
1 answer

Monix TaskLocal does not seem to reflect values from bind() call when referenced by Task by from different lexical scope

I have a block of code that is a slight modification of the code snippet given in the ScalaDoc for TaskLocal [ original here: https://monix.io/api/3.0/monix/eval/TaskLocal.html ]. My code simply replaces the inline task (within the for…
Chris Bedford
  • 2,560
  • 3
  • 28
  • 60
0
votes
0 answers

Retrying Monix Task - why Task.defer is required here?

I recently spotted a case I can't fully understand while working with Monix Task: There are two functions (in queue msg handler): def handle(msg: RollbackMsg): Task[Unit] = { logger.info(s"Attempting to rollback transaction ${msg.lockId}") …
Michal Ostruszka
  • 2,089
  • 2
  • 20
  • 23
0
votes
1 answer

how does building a big task computation compare to execute synchronously several steps?

I have the following two pieces of code written in Scala/Monix: def f1(input) = for { a <- task1(input) b <- task2(a) c <- task3(b) } yield (c).runSyncUnsafe and def f2(input) = { val a = task1(input).runSyncUnsafe val b =…
vidi
  • 2,056
  • 16
  • 34
0
votes
2 answers

How to make monix fixed rate Scheduler continue upon failure

I am just starting to use monix, in part for scheduling repeated work in a long running app. I will manage exceptions but I would like that monix continue calling the given function even if I let pass some of them. Now, from a simple test, once a…
Juh_
  • 14,628
  • 8
  • 59
  • 92
0
votes
1 answer

Understanding monix consumer load balance

I am learning monix 3. The next code: object Main extends TaskApp { override def runc = { Observable.fromIterable(1 to 10) .map{i => val delay = Random.nextInt(1000) + 1000 println(s"Starting $i, delay = $delay") …
Oleg
  • 899
  • 1
  • 8
  • 22
0
votes
1 answer

Idiomatic way to handle multiple concurrent streams in Scala

I have a list of streams that, upon calling their next() will sleep random amount of time and then read one char from a different source. I am trying to write a consumer(s) that will keep calling these streams until EOF and build a common dictionary…
smohamed
  • 3,234
  • 4
  • 32
  • 57
0
votes
1 answer

Akka Actor Searching and Streaming Events

I have a scenario where I have a bunch of Akka Actors running with each Actor representing an IoT device. I have a web application based on Play inside which these Actors are running and are connected to these IoT devices. Now I want to expose the…
joesan
  • 13,963
  • 27
  • 95
  • 232
0
votes
1 answer

What is `alsoTo` analogue of akka-streams in monix ?

Monix looks like great framework but documentation is very sparse. What is alsoTo analogue of akka-streams in monix ? Basically I want stream to be consumed by two consumers.
expert
  • 29,290
  • 30
  • 110
  • 214
0
votes
1 answer

How to handle recursion with monix's observable?

Using monix I'm trying to traverse a graph by building an Observable[Node] and using a breadth first algorithm. However there I have a bit of a recursion problem. Here is a snippet illustrating my problem: package gp import monix.eval.Task import…
lorilan
  • 311
  • 1
  • 9