Comments (8)
By the way, RxJS is not trying to be at all callbag compliant, they are just taking a few ideas and techniques from some callbag utilities, in order to reduce library size.
from callbag.
@jordalgo The fallback, where callbags have to forward anything they don't understand, is for IDs they don't support. But when two callbags support the same ID 10+ with conflicting meanings, that's the user's and/or callbag creator's problem to sort out - it's no different than conflicting event names, and it's an issue this doesn't solve.
from callbag.
This would help to determine whether a source is pullable or not, but only at consumption-time (i.e. not without beginning a handshake with the pullable).
If undefined/missing, it would default to [0] for convenience.
Because of this, there seems to be an easy path for making a compatible spec instead of mutating the current one.
from callbag.
Because of this, there seems to be an easy path for making a compatible spec instead of mutating the current one.
That was one of the minor goals of this: don't be too breaking. I was wanting to see about how
This whole thing was a thought experiment. If I were to write a greenfield "callbag"-style spec with this, I'd use objects with appropriate methods instead, like {...sink, greet(source) { ... }}
. They're a little less cryptic, and I can spread the extra methods instead of mandating raw proxying. They also make for easier querying, and I wouldn't need the ID system. Extensions that are domain-specific could just choose to use symbols to avoid clashing.
from callbag.
The object idea is quite a bit higher-memory and a little higher overhead, though, enough that I'm not quite comfortable with it. So maybe back to the drawing board. (This would be much easier to address in a statically typed language built for this, but that's not going to happen in JS.)
Oh, and now that I think of it, callbags remind me a lot of process calculus (particularly asynchronous π-calculus) and actors both, almost a simplified mix between the two. It lacks the mailbox of most actors and it lacks the built-in "replicate" that asynchronous π-calculus has, but much of the rest could be easily encoded (I probably got a few of these slightly wrong, but I'm not super well-versed in either):
- π-calculus concurrency:
P | Q
↔ create a callbag whereP
andQ
are invoked with the arguments passed in. - π-calculus communication, output-prefixing:
c̅⟨y⟩.P
↔ basically how you do handshakes now. - π-calculus "creation of a new name":
(vx) P
↔ just accept a new message type. - π-calculus nil process:
0
↔(id, talkback) => { if (id === 0) talkback(2) }
- Actor messages:
callbag(id, data)
- Create actor:
(id, talkback) => { ... }
- Designate behavior used for message:
if (id === 10) { ... } else { ... }
inside callbag.
Out of curiosity, was the actor model and/or any process calculi an inspiration for this?
from callbag.
@isiahmeadows - I like this idea. Does this only apply to the IDs in this callbag spec (e.g. not including any added later?). I'm asking because any additional IDs would have to be part of some other agreed upon spec otherwise they don't mean much e.g. RxJs using "3" for errors whereas another library uses "11".
from callbag.
@jordalgo It applies to all IDs, including non-standard IDs other people use. The "greeting with the various IDs" is meant to notify libraries of what's supported within the pipeline, so they can adapt accordingly. The rationale behind the required proxying is in cases like this, where I don't want that to get lost even though various operators. In that case, one could create an operator to lift and abstract it out of the sink using a custom ID with return value, and with this proposal, you could do that even after applying map
/filter
/etc.
By the way, I made a few changes to the proposal, notably I replaced arrays with functions.
from callbag.
@isiahmeadows I guess what I'm confused about is if the the meanings of the IDs are not standardized then two callbags could support the same ID with different meanings. Or am I missing something?
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
- 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.