Open butakovmv opened 7 years ago
```js
pipes: {
result: vm => vm.twoPipe.flatMap(two => vm.fixRandomPipe.map(r => two * r)),
fixRandom: vm => 42,
two: vm => vm.onePipe.map(one => one + 1),
one: vm => 1
}
This is the piece of code. What is twoPipe
and onePipe
? Where do you define it?
Show please all relative code.
:wink:
@Piterden I am? Nowhere) They were magickally defined in the library. I only use code from Readme: from line + 8 next:
pipes: {
one: vm => 1,
two: vm => vm.onePipe.map(one => one + 1),
fixRandom: vm => 42,
result: vm => vm.twoPipe.flatMap(two =>
vm.fixRandomPipe.map(r => two * r)
)
// result = (1 + 1) * 42 = 84
}
I shuffle keys in object and get the error
Every pipes-block is a sequential set of instructions, you can recognise it as a small programe on your own pipes-dsl. Every pipe is one line of your mini-program, of course if you change order of lines in your javascript code, then you'll get an error. so why wouldn't you get it in pipes? Your example the same as
const coll = [1,2,3].forEach(v => v + one);
const one = 123;
It has no sense right? So the same here)
Actually, It's possible to make it work, but with this feature - you will be able to write code with hidden bugs, for example here is an infinite loop
pipes: {
one: vm => vm.threePipe,
two: vm => vm.onePipe,
three: vm => vm.twoPipe,
}
This functional is just the same as go to Of course we are not talking about function-pipes
pipes: {
one: vm => () => vm.threeApply(),
two: vm => () => vm.oneApply(),
three: vm => () => vm.twoApply(),
}
When you are dealing with functions, of course you can make infinite loop, because functions is another level of managing control flow
:magic:
Code:
Error:
How to use a pipe described below?