问题标签 [reactive-programming]

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 回答
2456 浏览

haskell - 我使用的是反应香蕉吗?

这是一个使用 reactive-banana 库的 Haskell FRP 程序示例。我才刚刚开始对 Haskell 有所了解,尤其是还没有完全理解 FRP 的含义。我真的很感激对下面的代码的一些批评

这里有一个要点:https ://gist.github.com/1099712 。

我特别欢迎任何关于这是否是 accumE 的“好”使用的评论,(我不清楚这个函数每次都会遍历整个事件流,尽管我猜不是)。

此外,我想知道如何从多个套接字中提取消息 - 目前我在永远的内部有一个事件循环。作为一个具体的例子,我将如何添加第二个套接字(zeromq 用语中的 REQ/REP 对)来查询计数器内 IdMap 的当前状态?

0 投票
1 回答
1415 浏览

.net - How to get received message buffer from connected client socket using Socket and Reactive extension (Rx)

As i am bit new to Rx and learning my way through it. I checked out lots of examples out there but none fits my need.

Scenario : I have one socket server socket (created using simple socket object and not TCPListener object). I have multiple clients (client socket and not TCPClient) connected to this server socket. I am trying to use Rx (Reactive extension) to get the messages sent by client socket by using "FromAsyncPattern" operator for BeginReceive and EndReceive asynchrounous operation.

I have almost started getting the messages in the buffer. But the issue is that the buffer return either the same message received from previous operation or will have mix content from current and previous receive operation.

Here is the code used :

OnMessageReceived method is just an delegate to raise the message received event and send the buffer to other class to process further.

Problem : The same buffer is used evertime i get message how can i get the message received clean from previous received buffer.

-- What should be done if i have message received partially and the next message is actually part of this same message.

Please help me out with the above issue with some code snippets which would be greatful. Reason of posting this question is cause the implementation i have gone through till now are using TCPListener and here the constraint is to use socket object :(

Thanks in advance.

0 投票
2 回答
835 浏览

c# - 为什么 IObservable.First() 块?

最近,我一直试图了解 .NET 的 Reactive Extensions,但遇到了一些概念性问题:我无法弄清楚为什么 IObservable.First() 会阻塞。

我有一些看起来有点像这样的示例代码:

我期望发生的是itemA引用等于a并能够访问其成员等。相反,发生的是First()阻塞并且Assert.AreEqual()永远不会到达。

现在,我知道在使用 Rx 时,代码应该Subscribe()IObservables,所以很可能我在这里做错了。但是,根据各种方法签名来执行以下任一操作是不可能的:

或者

我错过了什么?

0 投票
1 回答
85 浏览

events - 是否可以从 Action 侦听器创建 IObservable?

我有一个将事件定义为的类Action<Guid>,而不是带有 EventArgs 的经典 EventHandler。有没有办法将其转换为 IObservable,就像使用标准 EventHandler 一样?我需要这样做,以便可以与其他 IObservable 合并。

0 投票
1 回答
3362 浏览

programming-languages - 函数响应式编程的“信号”表示是否正确?

我一直在研究 FRP,发现了一堆不同的实现。我见过的一种模型是我将其称为“信号”表示的模型。这一基本要素将事件和行为组合到一个实体中。

首先,信号是一个对象,其值为行为。其次,信号有一个事件“流”,可以作为标准数据结构查看和操作(您可以在信号上使用“每个”、“映射”和“过滤器”等来定义事件的反应方式)。例如,我可以这样做(其中“时间”是时间的信号表示):

FRP 的这种表示是否正确或有任何问题?我非常喜欢它的工作方式以及个人描述的简单程度,但我不确定它是否正确。

0 投票
2 回答
2287 浏览

system.reactive - 如何创建一个 Rx observable,当最后一个观察者取消订阅时停止发布事件?

我将创建一个可观察对象(通过多种方式)并将其返回给感兴趣的各方,但是当他们听完之后,我想拆除可观察对象,这样它就不会继续消耗资源。另一种将其视为在 pub 子系统中创建主题的方式。当没有人再订阅某个主题时,您不想再持有该主题及其过滤。

0 投票
1 回答
205 浏览

system.reactive - 是否有一个 Rx 框架函数将创建一个在时间跨度过去后结束的 observable?

有些 observables 实在太需要了。他们希望你听,听,听他们要说的一切,也许永远!如果我真的只能处理几秒钟的事件怎么办?我可以写类似的东西吗

从概念上讲,这将创建一个主题,该主题将传递事件直到某个时间过去,然后取消订阅底层可观察对象并将其自己的序列标记为完成。我怀疑您可以手动编写它,但似乎必须有一些现有的运营商这样做。我曾希望那Observable.TimeOut会做我想做的事,例如使用

但我认为如果观察之间的时间跨度长于给定值,它正在做的是超时观察。这也很有用,但不是我所追求的。

0 投票
1 回答
2197 浏览

signals-slots - “信号和槽”的概念是反应式编程吗?

正如标题中所写 - “信号和插槽”是一种简单的反应式编程方式吗?

0 投票
1 回答
180 浏览

idisposable - 预定一次性

什么是在 Reactive Rx中使用ScheduledDisposable的好案例/示例

我喜欢使用CompositeDisposableSerialDisposable,但你需要ScheduledDisposable吗?

0 投票
1 回答
698 浏览

haskell - 反应香蕉可以处理网络中的循环吗?

我们有这样的代码:

您可以看到 evtAutoLayout 输入 guiState,而 guiState 又输入 evtAutoLayout——所以那里有一个循环。这是故意的。自动布局调整 gui 状态,直到达到平衡,然后它返回 Nothing,因此它应该停止循环。当然,新的模型变化可以重新开始。

但是,当我们把它放在一起时,我们在编译函数调用中遇到了一个无限循环。即使 autoLayout = Nothing,它仍然会在编译期间导致堆栈溢出。

如果我删除 guiState 中的联合调用并从图片中删除 evtAutoLayout ......

它工作正常。

有什么建议么?