by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Matt Ross
    @amsross
    it feels a little weird with a tuple, an event emitter, and a required merge, but the main takeaway is that you’ll probably need to set up some state related to your segmented streams and pass values around based on/in that
    bkt
    @thomas-hilaire
    Wahou you did the job @amsross, thanks you! I was far from this kind of strategy to make it working, I will make a try! Now that you investigate so much about this use case, could it deserve a contribution with a new groupStream operator in the library?
    Matt Ross
    @amsross
    Unfortunately this solution is pretty targeted at node rather than the browser because of the dependency on EventEmitter
    beyond that, I think one of highland’s main claims is that it’s a high-level utility belt, so you have thinks like consume with which to capture any kind of custom state and/or logic handling on a case-by-case basis, so adding things like this probably won’t be useful to most people
    this is probably better fodder for a blog post or something like that
    I would also suggest diving a little deeper as this may not be a production-ready solution
    Matt Ross
    @amsross
    you might even be able to reproduce this more simply with a transducer or something like that
    joystick
    @joystick
    Hello, I'm looking for advise on following.
    Given I have a finite stream of (accounting) transactions from db1() I would like to split this stream into two (or more), e.g. transactions_out and accounts_out and sink them to db2(). What should I use to filter out accounts and sort/unique them? Thank you.
    Matt Ross
    @amsross
    Have you considered through?
    The argument to the function you pass is a stream, which you can then fork, filter, operate on, and merge the incoming stream values
    joystick
    @joystick
    @amsross Thanks for that, i will check it out! Forking and merging streams is yet unknown to me but matching the use case.
    Matt Ross
    @amsross
    for example:
    h([1, 2, 3, 4])
      .through(stream => {
        const evens = stream.fork()
          .filter(x => x % 2 === 0)
    
        const odds = stream.fork()
          .filter(x => x % 2 !== 0)
          .flatMap(saveToDb)
          .reject(() => true)
    
        return h([evens, odds])
          .merge()
      })
      .each(h.log) // 1 3
    joystick
    @joystick
    That's cool esp flatMap part! :+1:
    joystick
    @joystick
    Good day! Could you please advise me with a pattern for following? Given I have a stream of objects (a result of map). I would like this stream to emit only unique object which were not emitted before. Is it possible?
    Matt Ross
    @amsross
    joystick
    @joystick
    Unbeliavable! :+1:
    Stefano Vozza
    @svozza
    Michael Weichert
    @mweichert
    Hey all. I'm new to Highland, and working with streams in general. I use Fluture for most of my work. I've got myself in a situation where I need to run filter on a highland stream. However, my filter function currently returns a Future. :/ I've been trying lots of different things, like using map to coerce every value of the stream into a Future, and then using ap to apply transformations but it just seems a bit messy. Any suggestions? I essentially need to iterate over a the values of a stream, and apply a filter on it, but the filter is asynchronous.
    Stefano Vozza
    @svozza
    doesn’t fluture have methods to convert to a promise, could that work for you?
    ah wait, that’s the wrong way round for you
    can you give a little code snippet?
    Michael Weichert
    @mweichert
    Stefano, sorry for the very late reply. I just did as you said - converted it to a promise. That's sufficient for now I think.
    Stefano Vozza
    @svozza
    ah good stuff
    whiplash
    @whiplash
    hi, i'm pretty sure this has been asked already (sorry about that). i'm using axios to make an http request. i need to make that call every minute until i get something else than a 404. i don't see any combinator in highland for repeating the source every x seconds
    Stefano Vozza
    @svozza
    i’ve done this before by just making a simple recursive function
    you’re termination condition is the http code
    whiplash
    @whiplash
    so like a function f returning a promise that i can then _(f)...
    Stefano Vozza
    @svozza
    well you can do it with streams too but your way is probably simpler. in fact, you could just create an async function with a while loop if you are worried about blowing the stack
    async function f() {
      let res = await fetch(‘https://example.com);
      while(res.code !== 404) {
        res = await fetch(‘https://example.com);
      }
    }
    obviously you’ll want a sleep in there too
    then you’ll use _(f()) inside flatMap
    or whatever it is you want to do
    whiplash
    @whiplash
    thanks
    i'll give this a spin
    Stefano Vozza
    @svozza
    let me know how it goes!
    whiplash
    @whiplash
    yep
    but in general my question was more like "there is no built-in combinator" for "do this every X"
    like "repeat this stream every X"
    'cause i've browsed the api a bit
    but to no avail
    Stefano Vozza
    @svozza
    No there isn’t that specific combinator
    whiplash
    @whiplash
    ok
    thanks again
    Stefano Vozza
    @svozza
    no worries!
    are you thinking of something like this? https://rxjs-dev.firebaseapp.com/api/operators/repeatWhen
    whiplash
    @whiplash
    let me see
    haven't really used rxjs... i mean i know what it is... but yeah, something like that
    Stefano Vozza
    @svozza
    yeah me neither, could be a useful function for highland
    whiplash
    @whiplash
    i mainly work with scala, and used something called fs2 for similar issues
    Tim Wisniewski
    @timwis
    Oh hey! DIdn't realise there was a gitter room for highland. Is it possible to get an async iterable from a highland object? I'd like to be able to consume it with for-await-of if possible.