GraftJS / graft

full-stack javascript through microservices
http://graft.io
MIT License
227 stars 15 forks source link

Support seneca-like pattern matching in .where #23

Closed AdrianRossouw closed 9 years ago

AdrianRossouw commented 9 years ago

I was looking at @rjrodger's new zeno library and it got me inspired to see what it would look like in graft.

This changes the where matching to use the same combination of patrun and jsonic, so it makes the following possible.

var graft = require('graft')();

graft.where('hello:world', firstStream);
graft.where('hello:world, secondStream);

graft.write({hello: 'world'});

the result of that message will have similar semantics (although reversed) of seneca's this.prior. When you send the message, the result will be firstStream.pipe(secondStream);

There's probably still a mismatch between the functionality of seneca and this, but that may also be due to the fact that graft/streams define explicitly the order of execution.

AdrianRossouw commented 9 years ago

should also be possible to mount seneca proper using @mcollina's https://www.npmjs.com/package/seneca-act-stream

mcollina commented 9 years ago

:+1:

mcollina commented 9 years ago

The problem is getting results back. seneca-act-stream implies there is no reply.

mcollina commented 9 years ago

I'm kind of against this. jsonic is like 2000+ lines of code, and this is going to weight something in the browser.

AdrianRossouw commented 9 years ago

@mcollina while doing it I also started feeling it was wrong for this project. I made a PR mostly to be able to share/discuss.

It is the kind of thing that should be easy to add via an external module though, and easy to integrate with an external system that does this.

it did lead me to realize that the branching function should be asynchronous (for situations where you don't know if you are branching until you ask an external server).