Subscription grammar#
Subscription grammar is the compatibility module for lifecycle subscription declarations imported by the root grammar.
Source#
| Property | Value |
|---|---|
| Grammar file | packages/business/language/grammar/subscription.g4 |
| Grammar name | subscription |
| Grammar kind | parser |
| Imports | common, type, expression, literal |
| Imported by | BusinessLanguage, module |
| Direct rule or token count | 6 |
How to use this page#
Read the examples first when authoring Business Language. Use the rule inventory when checking exact grammar coverage or when updating parser, lowering, editor, or documentation behavior.
Entry rules and syntax families#
Start with these rules when reading this grammar: subscriptionDeclaration.
- Declarations:
subscriptionDeclaration
Key grammar excerpts#
subscriptionDeclaration#
subscriptionDeclaration
: annotation* SUBSCRIBE identifier ON TABLE typeExpression AFTER subscriptionOperation subscriptionDispatchMode? OPEN_PAREN parameterList? CLOSE_PAREN blockStatement
// @define @name_fields(identifier) @symbol(kind=global) @scope(level=2) @runtime_ast_export
;Complete rule and token inventory#
subscriptionDeclaration, subscriptionDeleteOperation, subscriptionDispatchMode, subscriptionInsertOperation, subscriptionOperation, subscriptionUpdateOperationExamples#
Update subscription#
subscribe InvoiceChanged on table Invoice after update async (
old_row: Invoice,
new_row: Invoice
) {
handle_invoice_change(old_row, new_row);
}Insert subscription#
subscribe VendorCreated on table Vendor after insert (new_row: Vendor) {
write_vendor_audit(new_row.vendor_id);
}Delete subscription without parameters#
subscribe VendorDeleted on table Vendor after delete() {
clear_vendor_cache();
}Async update with old and new rows#
subscribe VendorChangedAsync on table Vendor after update async(old_row: Vendor, new_row: Vendor) {
enqueue_vendor_refresh(new_row.vendor_id);
}Common authoring mistakes#
- Do not copy examples without checking the rule inventory for the exact grammar boundary.
- Do not add behavior that depends on missing configuration or undeclared user-facing errors.
Related guides#
- /language/lifecycle-subscriptions/
- /language/functions-services/
Authoring notes#
- Keep examples aligned with the grammar source, not with inferred syntax from another language.
- Use declared messages for user-facing failures, and fail closed when required configuration is absent.