Lifecycle

Learn more about the Lifecycle

Introduction

There are many scenarios, where you want to wait for the method to be completed before starting another one. That's why we create a custom lifecycle system for booting up the framework. In simple words, the lifecycle is kind of a queue, where each decorator runs after each other in a particular order.

This lifecycle does not affect the alt:V lifecycle. They only help you perform a different task on different steps.

Loader

We've created a Loaderservice to fit our needs for the lifecycle we want. Using the loader is recommended, and the setup is fairly easy. The only thing to do is, bootstrap your entry module, and the loader starts the magic.

This is available on the server and client side

import { LoaderService } from '@abstractflo/atlas-server';
const loader = container.resolve(LoaderService);

loader
    .bootstrap(ServerModule)
    .done(() => {
        // This method is called, if the lifecycle finished
    });

You don't need to load up other modules. Keep in mind, the available decorators do this for you.

Available Decorators

The done callback has a duration within 5000ms. If your task not over in this time, the console would show you some information about.

You can increase this time, by adding as argument to decorator

@Before()
public task(done: CallableFunction): void {
    setTimeout(() => {
        done();
    }, 5000)
}

Last updated