question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SUGGESTION: Functions or chains... does it matter?

See original GitHub issue

After 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:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:36 (32 by maintainers)

github_iconTop GitHub Comments

3reactions
christianalfonicommented, Feb 24, 2017

Haha, I thought about Promise.all when I went to bed yesterday… yeah, I think all creates a good bridge with Promise.all 😃

2reactions
tiagocpontespcommented, Feb 24, 2017

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/. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

What's the Best Effects Chain Order for Mixing? - Icon Collective
What's the Best Effects Chain Order for Mixing? ; 1. Gain Staging. Gain staging ; 2. Saturation. Saturation ; 4. Compression. Compression ;...
Read more >
Six ways to improve global supply chains - Brookings Institution
It used to be a simple matter to outsource production to other countries, have them manufacture clothes, electronics, computer chips, ...
Read more >
How to Sell Your Ideas up the Chain of Command
We've found that the key to selling your idea up the chain of command is to understand the psychology of ... How will...
Read more >
Chain Rule - Calculus - Cliffs Notes
The chain rule provides us a technique for finding the derivative of composite functions, with the number of functions that make up the...
Read more >
Chain functions in JavaScript - node.js - Stack Overflow
Your functions need to return an object that has a method(s) that will be called on it. You normally need a function like...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found