Comments (9)
Hi! Well, looks good. Maybe try it out in a real project a couple of times and see if it makes sense. :)
from callbag.
Challenge accepted 😉
from callbag.
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.
@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.
I don't know.
My idea would be to change the spec, but it's not tested thoroughly yet.
😃
from callbag.
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.
Do you have any cool naming ideas for the forked spec/library ?
from callbag.
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.
@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)
- Use named constants and non-zero power of two values for type parameter HOT 1
- Versioning HOT 1
- I'm missing something HOT 12
- Calling a sourceTalkback with 1 and data HOT 1
- How to handle additional websocket connection state HOT 1
- Consuming pullable sources needs careful handling to avoid stack overflow HOT 21
- More readable implementation of callback based duplex stream HOT 13
- Errors and Termination HOT 11
- Ability to discover what IDs a callbag supports HOT 8
- A more concise way HOT 6
- Are asynchronous handshakes permitted? HOT 1
- What if an exception is thrown during callbag execution? HOT 19
- sink termination propagation
- Confusion about spec HOT 7
- Control flow assumptions HOT 16
- Express variance in types HOT 12
- Ability to detect callbags
- Stricter types? HOT 1
- Missing index.js referenced from "main" in package.json breaks Vite HOT 1
- Why do we say sink is a callbag?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from callbag.