Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Brian Cavalier
    @briancavalier
    the name most-adapter came from the ports and adapters architecture: http://www.dossier-andreas.net/software_architecture/ports_and_adapters.html . It's an adapter in that sense
    @kanitsharma oops, sorry about that. I had previously published https://www.npmjs.com/package/@briancavalier/most-adapter but forgot to set access=public. I just made it public if you want to use it as a dependency instead of copy-paste
    I'll talk to the rest of the mostjs team about moving it to the mostjs org
    Kanit Sharma
    @kanitsharma
    Alright @briancavalier , thanks for the support 🙌
    Brian Cavalier
    @briancavalier
    @kanitsharma my pleasure
    Brian Cavalier
    @briancavalier
    @kanitsharma We just made @most/adapter official: https://github.com/mostjs/adapter
    npm i @most/adapter --save
    Kanit Sharma
    @kanitsharma
    Awesome :D
    Asad Saeeduddin
    @masaeedu
    Hi @briancavalier. Is there an issue somewhere for exposing lift2 :: (a -> b -> c) -> Stream a -> Stream b -> Stream c in the mostjs core API?
    or prior discussion here
    Brian Cavalier
    @briancavalier
    Hey @masaeedu. Take a look at combine, which is basically a varargs lift, and see if that’ll work for you
    Oh, sorry, I just noticed you said core API. In most 1.x, combine is varargs. In most/core, combine is exactly lift2. Either way, have a look and see if it’ll work for you
    Asad Saeeduddin
    @masaeedu
    ok, thanks
    BasH
    @bas080
    @briancavalier thnx for the explanation. I am using node streams for all kinds of things that aren't just IO. Object mode indeed. Thnx for mentioning most-node-streams. '
    sourcevault
    @sourcevault
    How to use the standard 'run interface ' ? I am trying to put node.js style callback ( different library than stds ) into a most stream
    this is most/core i believe

    https://mostcore.readthedocs.io/en/latest/api.html#stream

    doc is hard to digest without some examples :(

    how to create a stream interface ?
    sourcevault
    @sourcevault
    do i just used most 1.x most.create for nodejs style callback interface ?
    Brian Cavalier
    @briancavalier
    Hi @sourcevault
    Brian Cavalier
    @briancavalier
    The simplest thing is to implement the Stream interface. In Typescript, for example, that can mean literally implementing the interface: writing a class that implements Stream<A>.
    In plain JS, as usual, interfaces are implicit. You simply write a class or object that adheres to the duck type and contract of the Stream interface
    that is, it has a method named run that adheres to the contract described in the docs: https://mostcore.readthedocs.io/en/latest/api.html#stream
    Here's an example of a JS implementation of the stream interface: https://github.com/mostjs/dom-event/blob/master/src/index.js#L52-L67
    Hope that helps
    sourcevault
    @sourcevault

    Hi @briancavalier ! it looks like a lot has changed. I am still not quite sure how I can simple write a nodejs callback API in most stream.

    Thanks for writing @most/adapter ! I do not understand how it works underneath, but I really needed something like that.

    How would I write this bit in ES5 (taken from link) ?

    class DomEvent {
      constructor (event, node, capture) {
        this.event = event
        this.node = node
        this.capture = capture
      }
    
      run (sink, scheduler) {
        const send = e => tryEvent(currentTime(scheduler), e, sink)
        const dispose = () => this.node.removeEventListener(this.event, send, this.capture)
    
        this.node.addEventListener(this.event, send, this.capture)
    
        return { dispose }
      }
    }

    is it possible to show the example taken from @most/create, using the run interface ?

    
    import create from '@most/create'
    
    // Add events and then end
    const stream = create((add, end, error) => {
        setTimeout(add, 1000, 'event 1')
        setTimeout(add, 3000, 'event 2')
        setTimeout(() => {
            add('event 3')
            end()
        }, 10000)
    
        // OPTIONAL: Return a dispose function to clean up
        // resources when the stream ends
        return () => console.log('dispose')
    })

    Do we need to have a hard dependency on Babel ? or ES6 ?

    sourcevault
    @sourcevault
    currentTime = require('@most/scheduler').currentTime
    
    
    var $setTimeout = {
    
      constructor:function(userTime)
      {
        this.userTime = userTime
      }
    
      //----------------------------------------------------------//
    
      run:function(sink,scheduler)
      {
        var send = function(e)
        {
          tryEvent(currentTime(scheduler),e,sink)
        }
    
        var dispose = function(e) {return 0;}
    
        setTimeout(send,this.userTime);
    
        return dispose;
      }
    }
    
    function tryEvent (t, x, sink) {
      try {
        sink.event(t, x)
      } catch (e) {
        sink.error(t, e)
      }
    }
    that is the best i was able to understand :( , i still have no idea how to use '@most/types'.
    sourcevault
    @sourcevault
    is there a most-promise ? like promise but lazy ? or do we just create a most stream with a single value ?
    Galileo Sanchez
    @galileopy

    is there a most-promise ? like promise but lazy ? or do we just create a most stream with a single value ?

    I think you might want to look into different FL compatible libraries that implement Futures. @sourcevault

    sourcevault
    @sourcevault

    @galileopy i am not sure which Futures libs will work with most streams.

    For now I am okay with creating a stream with a single value ( it works fine and is good enough ) , most has most.fromPromise but not most.<insert future lib>

    Galileo Sanchez
    @galileopy
    I thought you wanted a "lazy promise", not a lazy promise that works with most xD
    So, yes, you'll be fine using single event streams.
    I don't remember if most was lazy, (run only on subscription), but if it is, it should be pretty easy to make a fromPromiseLazy(function), that would only run function if the stream is eventually subscribed.
    sourcevault
    @sourcevault

    @galileopy sorry if I was unclear.

    I do not understand why promises even exist but to bamboozle some folks.

    You do not get a say when the function CAN run. It runs in point of declaration which creates HUGE problems ( especially with error handlind and controling timing ).

    it should be pretty easy to make a fromPromiseLazy(function)

    I dont know if that is feasible, I do not even understand the inner working of mostjs.

    You have a declaration that you want to start at .run / .observe / .drain point of declaration, it should also be chainable.

    If I could figure out HOW to glue mostjs component with APIs in the wild it would save some lives.

    I tried writing something like @most/adapter a while ago, and I wasn't able to, so I abandoned that idea and used flyd.

    But for nodejs style callbacks mostjs is much nicer due to its laziness.

    Galileo Sanchez
    @galileopy
    most documentation doesn't really state that most streams are lazy
    :)
    Galileo Sanchez
    @galileopy
    @sourcevault it should be something like this, for most 1.x, and probably it would give you an idea of what you need to know to migrate to most/core
    const { Stream } = require('most')
    function LazyPromiseStream (promiseFn, args){
      return {
        run(sink, scheduler){
          promiseFn(...args)
            .then(
              result => sink.event(scheduler.now(), result),
              error => sink.error(scheduler.now(), error))
            .then(() => sink.end(scheduler.now()))
          return { dispose() { return null } }
        }
      }
    }
    
    module.exports = function fromLayzPromise(fn, args) {
      return new Stream( new LazyPromiseStream(fn, args))
    
    }
    Brian Cavalier
    @briancavalier
    @sourcevault @galileopy :wave: yes, mostjs streams are "lazy"--that is, inert until observed (e.g., via runEffects in @most/core, or observe in most)
    there are various ways to lift promises into mostjs streams, so you can pick whatever works for your particular situation. For example: fromPromise and awaitPromises are the basic promise-related operations, and those can be combined with map or chain, switch, mergeConcurrently, etc. to do a wide variety of things
    i still have no idea how to use @most/types.
    Brian Cavalier
    @briancavalier
    @most/types contains the foundational set of Typescript and Flow type definitions used across all @most/core based packages. It allows importing just those types. So, @most/types is only useful for projects using Typescript or Flow.
    sourcevault
    @sourcevault

    Hi,

    @galileopy thanks for providing the example ! exactly what I was looking for, cheers !

    @briancavalier I got what was needed from @galileopy | I will avoid looking at @most/types xD , due to my lack of knowledge in typescript.

    Brian Cavalier
    @briancavalier
    Cool. Cheers, @sourcevault
    Thanks for jumping in to help @galileopy
    Galileo Sanchez
    @galileopy
    NP, I do have a small package that makes a stream from a mutation observer, I should update it to use most/core, unlesss that was added or is to be added to most2.
    @briancavalier can you let me know if something like this is supplied with newer versions of most?
    https://github.com/galileopy/most-mutation/blob/master/index.js
    Brian Cavalier
    @briancavalier
    Hey @galileopy, sorry for the very late response :grimacing: . most/core's philosophy is to provide a useful set of combinators and a very minimal set of sources. We very much encourage the community to create sources based on dom-specific things, or node-specific things, or whatever they need. Your most-mutation package fits perfectly into that philosophy :)
    marcmartino
    @marcmartino
    i'm using @most/adapter to create a stream but i can't figure out quite how to terminate the stream when the time comes
    i suppose i could do a skipAfter on my ending event and force an end that way