Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Laszlo Korte
@laszlokorte
@atomrc yes, The proxy receives the "test" value before itself has any subscribers
You could either use a ReplaySubject or put the value$.subscribe(proxy$); call in the end
Thomas Belin
@atomrc
oh indeed putting it at the end is working, thk @laszlokorte
I find this pretty hard to understand at the beginning
Laszlo Korte
@laszlokorte
but is it clear now? Or should I elaborate?
Thomas Belin
@atomrc
No it's ok I got it thk :) The thing is I though this was my problem for the unit test I am writing but it not the same problem is seems :(
so I guess I'll have to dig a little deeper to find the source of my problem
fenduru
@fenduru
@staltz perfect timing with xstream - was literally just trying to convince my team to start incorporating FRP into our project, but they were looking for something lightweight to prove the concept
How do you create things like someStream$.withLatestFrom(otherStream$)? I can't seem to figure out how you would accomplish any sort of sampling with xstream
Adam Wendell
@AdamWendell
@frontendthug Was out with the dog :) The simplest thing that solves your problem is just to change to @cycle/dom": "^9.4.0".
Laszlo Korte
@laszlokorte
@fenduru someStream$.map((e1) => otherStream$.take(1).map(e2 => [e1, e2])).flatten() might work (@staltz mentioned something like this, I am not sure if I remember it correctly)
fenduru
@fenduru
@laszlokorte I think I would have to call .remember() on otherStream$ outside of the map, but yeah I think that's close
Andrey
@frontendthug
@AdamWendell it works, thanks!) but... is it bug or ... new api ? o_o
Steve Lee
@SteveALee
@laszlokorte now that's a useful tecnique I not thought of - closures within stream operators. Obvious now you show it :)
not as neat though
Adam Wendell
@AdamWendell
It's new api coming from the diversity branch. Which will give you the ability to chose a stream library instead of being forced to use Rx.
André Staltz
@staltz
@fenduru withLatestFrom is
Adam Wendell
@AdamWendell
This message was deleted
André Staltz
@staltz
otherStream.map(b => someStream.map(a => a+b)).flatten()
Andrey
@frontendthug
@AdamWendell cool ) and again, thanks for help and answers )
André Staltz
@staltz
withLatestFrom itself is not directly in the xstream API because it's the same as what I said and I'm trying to see how far can people go knowing only a few operators
fenduru
@fenduru
@staltz unless someStream is remember()'d for some reason
@staltz yep, keeping it light is good. Was just trying to figure out the best way
André Staltz
@staltz
You can then remember() after the flatten()
fenduru
@fenduru
If I were to advocate for something to facilitate use cases like this, I think a sampleBy method would be a good primitive.
xs.merge(someStream$, otherStream$).sampleBy(otherStream$)
André Staltz
@staltz
And making withLatestFrom in RxJS with flatMapLatest is harder because first you have to make the other stream hot. In xstream it's easier because everything is hot
Adam Wendell
@AdamWendell
@frontendthug No problems
André Staltz
@staltz
@fenduru we almost built withLatestFrom named as sampleCombine() in xstream. There you get the sampling name
But withLatestFrom is not so frequently used as the others, and we could just do map+map+flatten
fenduru
@fenduru
@staltz unfortunately I have only been able to use cycle.js for toy projects, but while trying to incorporate FRP into my work projects, I've found myself using withLatestFrom quite a bit. However I think I should have been using a reducer pattern in those cases instead /shrug
Alex
@whitecolor
Tylor Steinberger
@TylorS
Alex
@whitecolor
would this be: HTTP.flatMap(r$ => r$.catch(O.empty())) the only correct mechanics to get stream of only successful responses, do you use such approach?
Steve Lee
@SteveALee
I also ended up using withLatestFrom in my app as I gravitated to single state atom and yiu need to it get it on an unser event. I plan to change that though. I agree light is the way to go. While withLatestFrom could be added to extras, there's nothing to stop us creating a utility function. or even add it as an operator in our project if we really want to.
But this highlights that need for a resource of common patterns / idioms
@staltz so 'one' to going hot only :)
Thomas Belin
@atomrc
Hey, do you have any idea how I can get the last produced value of a not completed stream ?
is it even possible?
the underlining problem is when I am doing unit testing on my components. I have a component that depends on a continuous stream (DOM events typically) and I just want to test the last value of the vtree, how can I do that?
Maybe the answer is simply: I must only produce a single value when I am unit testing. I guess that's the path I am going to take right now ...
Alex
@whitecolor
what do you mean by "last of not completed"
Thomas Belin
@atomrc
to be honest, I am not even sure why my component is producing 2 vtrees for my test
@whitecolor well I think I am not able to really think in the "observable mode" yet, so the concept of "last produced value of a not completed stream" would be the last value that has been produced when something is subscribing :s
what I am saying sounds awful :D
maybe the way to do that is to just skip the nfirst uninteresting values?
Alex
@whitecolor
is it a hot stream?
Thomas Belin
@atomrc
well if DOM.select('.selector').events('click') is hot, then mine is hot
Tylor Steinberger
@TylorS
@atomrc All of the @cycle/dom tests use .skip(1).take(1)
Thomas Belin
@atomrc
@TylorS oh interesting indeed :)