Mayd JS Bundles
The Mayd backend uses bundles in JS. This enables us to optimize the performance, as well as be able to add initialization code in different bundles. The bundles are pretty basic:
class MyBundle extends MaydBundle
{
public constructor (mayd: Mayd.Application)
{
super(mayd);
// You should register all your services here, that have no dependencies
// to services in other bundles.
mayd.set("test", new Test());
}
public configure() : void
{
// You can configure all services here, that have dependencies on other services.
// If these relations are only setup in `configure` as well, you should
// use a factory method instead. All core services will be available, though.
this.mayd.set("some.integration", new SomeIntegration(this.get("form.widgets"));
}
public run () : void
{
// All your initializations and mounts should go here.
}
public runCritical () : void
{
// Only the absolutely critical initializations should happen here.
// That should only be components where it's very likely that the
// user wants to interact with them right away (like a main navigation).
}
}
This bundle architecture allows us to easily set up the service container, as well as defer all non-critical initializations after the initial page load.
Frontend
While this bundle architecture is only used in the backend for now, it might make sense to also use it in the frontend (maybe with renamed classes).
Table of Contents