-
Notifications
You must be signed in to change notification settings - Fork 78
Description
Enhancement
To use a stores, routing, theming and i18n requires consumers to manually register each one with a registry and pass the registry when mounting the application.
Current Example:
import { tsx } from '@dojo/framework/widget-core/tsx';
import renderer from '@dojo/framework/widget-core/vdom';
import Registry from '@dojo/framework/widget-core/Registry';
import { registerThemeInjector } from '@dojo/framework/widget-core/mixins/Themed';
import theme from './MyTheme';
import App from './App';
const registry = new Registry();
const themeInjector = registerThemeInjector(theme, registry);
const r = renderer(() => <App />);
r.mount({ registry });
The boilerplate required increases for each feature that leverages injectors. It would be ideal if injectors could be automatically registered with the applications registry. If there is no registry passed to the renderer a registry it would be created internally.
To ensure that only code required is included in the end users bundle, this could require some thought on the build process on how we could elide the feature registration modules.
A consideration will be that some injectors require values to be passed during the registration, for example the routing configuration when registering the router.
A possible example:
import { tsx } from '@dojo/framework/widget-core/tsx';
import renderer from '@dojo/framework/widget-core/vdom';
import theme from './MyTheme';
import App from './App';
const r = renderer(() => <App />);
r.mount({ injectors: { theme }});
Passing theme
would automatically factory a registry for the application and register the theme injector.