UNPKG

1.03 kBMarkdownView Raw
1# Decorators
2
3Both [event handlers](EventHandlers.md)
4and [command handlers](CommandHandlers.md) work
5with [TypeScript decorators][decorators]. These identify values that
6will be injected into a fresh instance each time the handler runs. If
7you're familiar with Spring, this will be particularly intuitive.
8
9[decorators]: https://www.typescriptlang.org/docs/handbook/decorators.html (TypeScript Decorators)
10
11Consider the following code within a command handler:
12
13```typescript
14@Parameter({
15 displayName: "Desired Spring Boot version",
16 description: "The desired Spring Boot version across these repos",
17 pattern: /^.+$/,
18 validInput: "Semantic version",
19 required: false,
20})
21public desiredBootVersion: string = "1.5.6.RELEASE";
22```
23
24The value of the `desiredBootVersion` parameter (if provided) will be
25injected into an instance before the `handle` function is called.
26
27The decorated variable names the parameter. If you assign a value to
28the variable, as in the example, it becomes the parameter’s default
29value.