Skip to main content

@destroy

The @destroy decorator is used to mark the destroy method in a block. That method is invoked when the block is destroyed. It receives a props argument with information about the reason why the block is destroyed. It can be used to cleanup things or cancel pending actions.

info

It can be used to decorate a method in a NodeBlock or HeadlessBlock derived class.

Decorator type

Method ℹ️

Applies to

Decorator signature

@destroy

Decorated method signature

(props?: {
type: "left" | "canceled";
}): void;

Decorated method parameters

NameTypeOptionalDescription
propsobjectYesSpecifies the properties for the destroy method. Contains the following properties:
- type: Specifies the reason for the destroy. Can be left which indicates the runner has left the block and now renders the next block. Or canceled which indicates the runners went backward and renders the previous block.

Example

import { tripetto, destroy, NodeBlock } from "@tripetto/runner";

@tripetto({
type: "node",
identifier: "example-block",
})
class ExampleBlock extends NodeBlock {
@destroy
destroyMe(props: { type: "left" | "canceled" }): void {
console.log(`This block is ${props.type}!`);
}
}