StartupSnapshot

sealed external interface StartupSnapshot(source)

Functions

Link copied to clipboard
abstract fun addDeserializeCallback(callback: StartupSnapshotCallbackFn, data: Any? = definedExternally)

Add a callback that will be called when the Node.js instance is deserialized from a snapshot. The callback and the data (if provided) will be serialized into the snapshot, they can be used to re-initialize the state of the application or to re-acquire resources that the application needs when the application is restarted from the snapshot.

Link copied to clipboard
abstract fun addSerializeCallback(callback: StartupSnapshotCallbackFn, data: Any? = definedExternally)

Add a callback that will be called when the Node.js instance is about to get serialized into a snapshot and exit. This can be used to release resources that should not or cannot be serialized or to convert user data into a form more suitable for serialization.

Link copied to clipboard
abstract fun isBuildingSnapshot(): Boolean

Returns true if the Node.js instance is run to build a snapshot.

Link copied to clipboard
abstract fun setDeserializeMainFunction(callback: StartupSnapshotCallbackFn, data: Any? = definedExternally)

This sets the entry point of the Node.js application when it is deserialized from a snapshot. This can be called only once in the snapshot building script. If called, the deserialized application no longer needs an additional entry point script to start up and will simply invoke the callback along with the deserialized data (if provided), otherwise an entry point script still needs to be provided to the deserialized application.