Skip to main content
Version: Next

QodlyEvents

Overview

The QodlyEvents class provides a structured approach to handling application lifecycle events in a Qodly Server environment. It enables developers to execute specific logic during application startup and shutdown.

tip

The QodlyEvents class is a shared singleton, meaning a single instance is globally available without needing manual creation. You can access it directly via the .me property without instantiating a new instance.

Functions and properties

.onStartup( { ...param : any } ) : void    triggers the onStartup() function logic defined in the QodlyEvents class interface.
.onStop( { ...param : any } ) : void    triggers the onStop() function logic defined in the QodlyEvents class interface.
.me : cs.QodlyEvents    returns the current instance of the QodlyEvents singleton.

.onStartup()

.onStartup( { ...param : any } ) : void

ParameterTypeDescription
paramanyParameter(s) to pass to the function

Description

The .onStartup() function triggers the onStartup() function logic defined in the QodlyEvents class interface. The .onStartup() function executes automatically when the server starts by calling cs.QodlyEvents.me.onStartup().

Additionally, developers can manually execute .onStartup() when needed, such as:

  • Explicitly triggering the startup logic from another function.
  • Running initialization logic without restarting the server.

Example

cs.QodlyEvents.me.onStartup({ config: "default" })

.onStop()

.onStop( { ...param : any } ) : void

ParameterTypeDescription
paramanyParameter(s) to pass to the function

Description

The .onStop() function triggers the onStop() function logic defined in the QodlyEvents class interface. The .onStop() function executes automatically when the server shuts down by calling cs.QodlyEvents.me.onStop().

Additionally, developers can manually execute .onStop() when needed, such as:

  • Explicitly triggering the shutdown logic before stopping the server.
  • Running cleanup operations without actually stopping the server.

Example

cs.QodlyEvents.me.onStop({ saveState: true })

.me

.me : cs.QodlyEvents

ParameterTypeDescription
Resultcs.QodlyEventsReference to the QodlyEvents singleton instance.

Description

The .me property returns the current instance of the QodlyEvents singleton.

It must be used when calling functions like onStartup() or onStop().

Why .me is Required:

If you attempt to call:

cs.QodlyEvents.onStartup()

You will encounter an error: The function or property onStartup does not exist on type cs.QodlyEvents. (550.2).

The correct way is:

cs.QodlyEvents.me.onStartup()

The .me ensures the function is being called from the current active instance of the QodlyEvents singleton.