SUGGESTION: Functions or chains... does it matter?
See original GitHub issueAfter some discussions with @tiagocpontesp and I am suggesting a possible change to function-tree
which will clean up quite a bit. We have been talking around these concepts earlier, but nothing concrete has come out of it yet. So!
[
actionA,
...chainB,
[
actionC,
...chainD
]
]
This is how we define actions and chains now. This code actually has a bug. If chainD
was defined like this:
[
[
someAction,
someOtherAction
]
]
function-tree
would throw an error.
The suggested change is to be able to write like this:
[
actionA,
chainB,
PARALLEL(
actionC,
chainD
)
]
That means function-tree
automatically figures out if it is a function or an array you insert. If it is a function it works as normal of course and if it is an array, it will merge it in for you. No need for spread. It basically just flattens all nested arrays.
When you want something to run in parallell you explicitly say so. Again, the arguments works the same way, does not matter if it is just a function or array.
Summary
The point here is to clean up signals. No more spread or “hard to read” arrays in arrays. Conceptually it does not matter if spread is there or not, the name of the chain is what makes sense.
It would allow for new patterns where you do not explicitly create folders for every kind of item in a signal (actions, chains, signals etc)… you could rather do things like:
/modules
/moduleA
/factories
someFactory.js
someAction.js
someChain.js
index.js
You would not be forced to separate so much by folders.
Tell me what you think 😃
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:36 (32 by maintainers)
Top GitHub Comments
Haha, I thought about Promise.all when I went to bed yesterday… yeah, I think
all
creates a good bridge withPromise.all
😃on the server i place the chains in “./_stories”, so i know i can throw any contents on an function-tree “runner”, and leave the inner folder structure as whatever makes sense for their invokers. some room has been made, by not to having to separate actions/ and chains/. 😃