Giter VIP home page Giter VIP logo

Comments (9)

staltz avatar staltz commented on June 3, 2024 2

Hi! Well, looks good. Maybe try it out in a real project a couple of times and see if it makes sense. :)

from callbag.

DrJume avatar DrJume commented on June 3, 2024 2

Challenge accepted 😉

from callbag.

DrJume avatar DrJume commented on June 3, 2024 1

What do you think about this?

const Producer = {
  connect(Consumer) {
    this.i = 0
    this.id = setInterval(() => {
      Consumer.data(this.i++)
    }, 1000)

    Consumer.open(this)
  },

  data(payload) {
    this.i = payload
  },

  end() {
    clearInterval(this.id)
  }
}

const Consumer = {
  open(Producer) {
    setTimeout(() => Producer.data(17), 3500)
    setTimeout(() => Producer.end(), 7500)
  },

  data(payload) {
    console.log(payload)
  }
}

Producer.connect(Consumer)

from callbag.

acailly avatar acailly commented on June 3, 2024

@DrJume I like the wording.
I see you're calling Consumer.data(...) directly, how would this work if the Consumer is a raw (not verbose) callbag?

from callbag.

DrJume avatar DrJume commented on June 3, 2024

I don't know.
My idea would be to change the spec, but it's not tested thoroughly yet.
😃

from callbag.

staltz avatar staltz commented on June 3, 2024

I can see where @DrJume is going towards, and I think it could work. One additional method could be toCallbag which returns a function (a callbag). See e.g. https://github.com/staltz/callbag-pseudo-rxjs/blob/52f04f7e6c06648374da6d1949694aa06013459d/index.js#L68

That also means an object with data/end/etc is not a callbag. It's a thing that can be converted to a callbag. So maybe you could make a separate library or spec for objects that follow that shape. (Specs are cheap to create, just make it)

My idea would be to change the spec, but it's not tested thoroughly yet.

Don't change the spec. Fork it, make another one. 😎

from callbag.

DrJume avatar DrJume commented on June 3, 2024

Do you have any cool naming ideas for the forked spec/library ?

from callbag.

bloodyKnuckles avatar bloodyKnuckles commented on June 3, 2024

As far as names go, when I first heard André share the discovery that, simply, "a Pull is just two Pushes" the first thing came to mind is Doctor Doolittle's "Pushmi-Pullyu" https://youtu.be/pmp-ITOI0-I?t=38s . :)

I wondered about the name Callbags, but then recently in one of André's talks he mentioned that if you take two callback hells, put them each in a bag, then connect the bags together you get heaven—then it clicked. :) Maybe I heard that explanation here: https://youtu.be/HssczgaY9BM

from callbag.

staltz avatar staltz commented on June 3, 2024

@DrJume Anything you feel like, but here are a few suggestion: objectbag, objbag. Note that forking specs to convert from object prototype methods to functions (or vice-versa) is okay and has happened in other communities, e.g. https://github.com/fantasyland/fantasy-land and then https://github.com/rpominov/static-land

from callbag.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.