问题标签 [monifu]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
292 浏览

scala - 以特定顺序向订阅者发送事件并带有背压的主题

想象一下您向其发出事件的订阅者管道,它一个接一个地访问一个订阅者。

有一个 PublishSubject 和 x 个订阅者/观察者。通常,事件会以特定顺序发送给观察者,但同时不管观察者何时返回。是否可以执行此流程:

  1. 向观察者A发出事件
  2. osbserverA 返回后,将事件发送给observerB
  3. 在observerB返回后,将事件发送给observerC

我正在使用RxScalaMonifu Rx 实现

Monifu 甚至有一个背压实现:

我希望在此示例中打印出“结果是:已更改!! ”:

在 RxScala/RxJava 或 Monifu 中是否可以不扩展 Subject 并覆盖 onNext 实现?无论如何,这些类都被声明为最终的,所以它会相当黑客。

0 投票
1 回答
721 浏览

javascript - Is Javascript event loop task queue overflow possible?

Is it possible to define a boundary that shouldn't be crossed for the application to scale well regarding task scheduling (over)use?

Questions :

  1. Is there a certain cost of doing setTimeout? Let say 0.1ms or CPU time? There is certainly order of magnitude lower cost than spawning a thread in different environments. But is there any?
  2. Is it better to avoid using setTimout for micro tasks that take like 1-2 ms ?
  3. Is there something that doesn't like scheduling? For instance I noticed of some sort of IndexedDb starvation for write locks when scheduling Store retrieval and other things
  4. Can DOM operations be scheduled safely ?

I'm asking because I started using Scala.js and an Rx implementation Monifu that is using scheduling at massive scale. Sometimes one line of code submits like 5 tasks to an event loop's queue so basically I'm asking myself, is there anything like task queue overflow that would slow the performance down? I'm asking this question especially when running test suites where hundreds of tasks might be enqueued per second.

Which leads to another question, is it possible to list cases when one should use RunNow/Trampoline scheduler and when Queue/Async scheduler in regards to Rx? I'm wondering about this every time I write stuff like obs.buffer(3).last.flatMap{..} which itself schedules multiple tasks

0 投票
1 回答
370 浏览

scala - Scala Rx Observable 使用 Monifu

我只是想掌握可观察的热和冷之间的概念,并尝试使用 Monifu 库。我的理解是,下面的代码应该导致只有一个订阅者获得 Observable 发出的事件,但事实并非如此!

所以,对我来说,这看起来像是 Observable 正在向所有感兴趣的订阅者发布事件?

0 投票
2 回答
343 浏览

scala - 如何在 Monix 中全局订购多个有序的 observables

假设我有多个有序的迭代器。如果我想合并这些迭代器,同时[(1,3,4), (2,4,5)] -> [1,2,3,4,4,5]使用monix对它们进行全局排序(例如) ,我会怎么做?