How to solve this basic ES6-module circular dependency problem?

Mikael Sand msand at abo.fi
Sun May 28 13:04:25 UTC 2017


Constructor injection should work as expected in any environment 
compatible and compliant with the ES6 and module specs. Or any 
functional environment with a module system.

Imho, it is the simplest and easiest to understand solution as well, it 
only removes code and adds two parameters. Thus expressing exactly what 
part is dependent on A and B in a parameterized reusable way, without 
any static cyclic dependencies. And without any complexity in the module 
initialization / resolution / evaluation.

Just reading the code once allows me to think about the entire flow, 
without keeping more than three concept in mind at once. Essentially 
allowing me to predict the entire execution of the program, without even 
running it.



More information about the es-discuss mailing list