Comments (4)
I'm assuming this pattern for pipe is somehow contrary to the design of flyd?
IIRC the reason we went for a single function passed to pipe was because we didn't want to introduce the complicated TS required to type such a pipe function.
Ultimately pipe is a pretty generic thing, have you considered using something like remeda's pipe?
R.pipe(
mystream,
flyd.filter(value => value !== 'foo'),
flyd.skip(1),
flyd.dropRepeats(),
flyd.map(console.log)
)
from flyd.
It will be nice to have this supported by the flyd lib. I've had a look at the API of a bunch of other similar libraries but I really like the fact that you have gone with pipe
(which many other's don't seem to have).
There's nothing terribly wrong with chaining multiple pipe
calls, but in the land of FRP these small deviations can grate, something explained quite well in this article on FRP.
Happy to help with the TS bits if needed.
from flyd.
I would hesitate to change it if it's only for stylistic preference. As mentioned, pipe
is a pretty generic function that you can easily implement outside any library and can then use with any of your types.
const pipe = (x, f, ...fs) => fs.reduce((x, f) => f(x), f(x))
from flyd.
I've added the following to the lib locally:
Code
function operator_pipe(...fns) {
return fns.reduce((x, f) => f(x), this);
}
Typing
pipe<R>(op: OperatorFunction<T, R>): Stream<R>;
pipe<A1, V>(op0: OperatorFunction<T, A1>, op1: OperatorFunction<A1, V>): Stream<V>;
pipe<A1, A2, V>(op0: OperatorFunction<T, A1>, op1: OperatorFunction<A1, A2>, op2: OperatorFunction<A2, V>): Stream<V>;
pipe<A1, A2, A3, V>(
op0: OperatorFunction<T, A1>,
op1: OperatorFunction<A1, A2>,
op2: OperatorFunction<A2, A3>,
op3: OperatorFunction<A3, V>,
): Stream<V>;
pipe<A1, A2, A3, A4, V>(
op0: OperatorFunction<T, A1>,
op1: OperatorFunction<A1, A2>,
op2: OperatorFunction<A2, A3>,
op3: OperatorFunction<A3, A4>,
op4: OperatorFunction<A4, V>,
): Stream<V>;
Where
interface UnaryFunction<T, R> {
(source: T): R;
}
interface OperatorFunction<T, R> extends UnaryFunction<Stream<T>, Stream<R>> {}
This works for me. Happy to close the issue if it's not going to be supported.
from flyd.
Related Issues (20)
- add more dependency for existing combine HOT 7
- Merge stream delay HOT 6
- add package.module
- Drag 'n Drop example is broken HOT 2
- Compare previous state with current state HOT 14
- Feature Request - Supply metadata for a combined stream HOT 2
- Help to build control flow func HOT 3
- Do you think this Promise -> Stream conversion is a right alternative way? HOT 6
- Wrong chain + setImmediate behavior HOT 1
- Benchmark against Most.js HOT 3
- Can flyd streams be made lazy ? HOT 9
- HELP: Trouble reading api documentation HOT 1
- Enhancement: Add Readonly-Streams (at least in Typings) HOT 3
- What's the motivation for ending a stream? HOT 3
- question on serialize stream
- from Node stream HOT 2
- Question: Required (code) complexity for higher-order streams HOT 10
- [Help Needed] CombineLatest in the style of RxJs HOT 17
- Switch Latest without Ramda Dependency HOT 6
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 flyd.