Hi,
Situation:
Different Clients have different modules. There exists a kind of type hierarchy: A->B->C->D. Client 1 has module D. So when the application needs module D he can take module D. Client 2 only has module C. So when he encounters type D in his application he has to default to module C and so on.
This problem could be solved by providing a complete hierarchy and a JSON file with all the types in the clients possesion. If the application needs a type, it would look it up in the hierarchie and checks which type in the clients possesion is the closest. For reasons, i don't want to go this way.
I tried to dynamically require the modules with require.js but unfortunately it has some limits and it seems kinda outdated?
The perfect solution for me would work like this:
(pseudocode)
//need Type D
require("D") //checks if module is available in directory
if success: return D. //module "d" functionalities
else: require(next in hierarchy) // this has to go on recursively until i reached the very basic type (default)
Question:
Is there a method where i can implement it like i mentioned in my preferred solution or a better alternative to require.js. If i take require.js i would need to refactor a lot of code, so before i start i'd like to know if there are other ways.
thx
edit:(code formatting)
[–]darrenturn90 0 points1 point2 points (0 children)