Last date modified: 2026-Jul-14

Executing Custom Code

You can configure extensions to execute custom code at specific application lifecycle events. Your code has access to the full IReviewInterfaceApi when executing.

This page contains the following information:

Custom code execution

To execute custom code in an extension, return an IExtensionConfig object that contains the lifecycle property. This property defines handlers that run when specific application lifecycle events fire.

Custom code example

Copy
import type { IExtensionParameters, IExtensionConfig, IReviewInterfaceApi } from 'reviewapi';

export default function(parameters: IExtensionParameters): IExtensionConfig {
  return {
    id: 'relativity.examples.customcode',
    name: 'Custom Code Example Extension',
    lifecycle: {
      ready: (api: IReviewInterfaceApi) => {
        console.log('The application is ready.');
        // Your custom code has access to the full API here.
      },
    },
  };
}

Available application lifecycle events

For functional and performance reasons, choose the appropriate lifecycle event when writing your extension. See IExtensionLifecycle for lifecycle event reference content.

Each lifecycle event handler receives the IReviewInterfaceApi as a parameter, giving your custom code full access to the API.

Event name Description
apiready Fired during application bootstrap when the API is ready for use. api.viewer.mainCollection exists but the first document has not yet loaded.
ready Fired when application startup is complete and a document is presented to the user.
activated Fired when the application is activated and the user can interact with it.
canDeactivate Fired just prior to application deactivation to determine if it is safe to deactivate.
deactivated Fired when the application is deactivated and the user can no longer interact with it.
canTeardown Fired immediately prior to the application being torn down to determine if it is safe to do so.
teardown Fired when teardown is approved and the application is being unloaded from memory.
Return to top of the page
Feedback