A CommandOptions object containing the unique command ID
Decorator function that registers the command class
// Basic command definition
@Command({ id: 'generate-pdf-report' })
export class GeneratePdfReportCommand implements AnyCommand {
public reportType: string;
public includeCharts: boolean;
}
// Single-object command with context
@Command({ id: 'archive-deal' })
export class ArchiveDealCommand implements LimeObjectCommand {
public context: LimeWebComponentContext & { limetype: string; id: number };
public reason: string;
}
// Bulk command with filter
@Command({ id: 'bulk-update-status' })
export class BulkUpdateStatusCommand implements LimeObjectBulkCommand {
public context: LimeWebComponentContext & { limetype: string };
public filter: Expression | null;
public newStatus: string;
}
// Register in CommandRegistry for type safety
declare module '@limetech/lime-web-components' {
interface CommandRegistry {
'generate-pdf-report': GeneratePdfReportCommand;
'archive-deal': ArchiveDealCommand;
'bulk-update-status': BulkUpdateStatusCommand;
}
}
// Now you can use createCommand with type safety
const command = commandBus.createCommand({
id: 'generate-pdf-report',
params: { reportType: 'monthly', includeCharts: true }
});
Decorator to register a class as a command with a unique identifier.
The
@Commanddecorator marks a class as a command and assigns it a unique ID that can be used for command lookup, registration, and execution. This decorator is essential for the command pattern implementation and enables type-safe command creation through the CommandRegistry.