Equivalent to Rx.Subject
See original GitHub issueHello everyone, I’m new to most and I was wondering if there is an equivalent to Rx’s Subject?
In particular, I’m curious if there is a way for recreating Rx.ReplaySubject
For some more information on what I’m trying to accomplish.
I’m trying to rewrite Cycle.js using Most instead of RxJs. I haven’t been able to find a way to recreate the circular dependency between Observables.
In Cycle.js it’s roughly like this (although a little more complex)
const sinksProxy = new Rx.Subject()
const sources = driverFn( sinkProxy )
const sinks = application( sources )
sinks.subscribe( value => sinksProxy.onNext(value) )
Thanks in advance!
Issue Analytics
- State:
- Created 8 years ago
- Comments:18 (7 by maintainers)
Top Results From Across the Web
Is there an equivalent of Subject for RxJava's Single?
Unfortunately there is no equivalent available in RxJava 1. However, as you have mentioned, you can achieve the desired result by calling ...
Read more >Subject - RxJS
What is a Subject? An RxJS Subject is a special type of Observable that allows values to be multicasted to many Observers. ·...
Read more >Types of Subjects in RxJava. Subjects are both an Observer ...
Subjects are both an Observer and Observable, it's like a proxy multicasting device or ... ReplaySubject is similar to cache() operator.
Read more >Intro to Rx - Key Types - Introduction to Rx
AsyncSubject<T> is similar to the Replay and Behavior subjects in the way that it caches values, however it will only store the last...
Read more >Subjects - Learn RxJS
Typical observables would be comparable to a 1 on 1 conversation. There are 4 variants of subjects: Subject - No initial value or...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For anyone else looking for this, I have an implementation here https://github.com/TylorS/most-subject. In combination with https://github.com/mostjs/hold a ReplaySubject-like stream can be created though only with 1 past value, as that’s the common use case.
@briancavalier Do you think it is safe to close this?
Hey @TylorS, this is a really interesting situation–one I’ve not really thought about before. I’d love to find a way to do it declaratively, rather than having to subscribe and feed the events back in. It’s totally not obvious how to do it declaratively right now, though (but I’ll give it more thought!)
Anyway, I think it would be annoying to try to do it in the current version of most.js. There’s been some previous discussion about providing an externalized imperative event pushing api in #72. That PR is a bit long in the tooth, and should probably be abandoned, but the idea certainly seems like it’d work for what you’re doing in that sample code.
One question: How do external events make their way into the cycle? Does someone (perhaps code inside
driverFn
orapplication
end up callingsinkProxy.onNext
?I went back and forth on adding an API like that, since it tends to either put the burden managing race conditions on the caller, or introduce inefficiency if you force every event to be queued and sent in a future call stack. But I’ve made my peace with it 😃
Would it work for you if there were some new API that looked like:
Thoughts?