HallM / jsframework

0 stars 0 forks source link

Refactoring the Core system #28

Open HallM opened 8 years ago

HallM commented 8 years ago

If the "Core" scripts could become composable, it would make it easier and cleaner to generate different bundles with pre-built boilerplate. Something like:

ReactRouter(ReduxState(ReactViewEngine(Core())))

Which allows each successive function to enhance Core with more capability.

Part of this refactoring, a good look at how Core pulls in dependencies such as View Models and how those dependencies in turn rely on Core. One possibility is the factories can become factory-factories (I know... I know...) and get what they need passed in.

Expanding on the factory-factory is relying on the functional-composition above anyway to even add ViewModel capability at which point Core should be defined enough to use.

ViewModels(Server(Router(Core())))

Downside? Things have to be initialized in a specific order, but the bundles do it anyway for users. Could have like a Factories bundle that is (or well, any Bundle, even Bundles of Bundles)

Factories = function(Core) {
  return Methods(ViewModels(Core));
}

and thus allowing us to call

Factories(Server(Router(Core())));

For loaders? Two options: 1) The ViewModel factory-factory created the factory, then handles the loading itself

2) Could have auto-loader components:

ViewModelLoaders(MethodLoaders(EnhancedCore))