Skip to content

Commit

Permalink
Update typescript-decorators.md
Browse files Browse the repository at this point in the history
  • Loading branch information
marwie authored Sep 17, 2024
1 parent 170664a commit 0232e7a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion documentation/reference/typescript-decorators.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ export class ButtonObject extends Behaviour {


### SyncField

The `@syncField` decorator can be used to automatically network properties of your components for all users (visitors of your website) connected to the same networking room. It can optionally take a callback function that will be invoked whenever the value changes.

*NOTE:* To notify the system that a reference value (like an object or an array) has changed you need to re-assign the field. E.g. like this: `myField = myField`
*NOTE:* The callback function can *not* be an arrow function (e.g. `MyScript.prototype.onNumberChanged` works for `onNumberChanged() { ... }` but it does not for `myNumberChanged = () => { ... }`)

```ts
export class MyScript extends Behaviour {

Expand Down Expand Up @@ -90,4 +96,4 @@ class YourClass {
// optionally return false if you want to prevent the default behaviour
}
}
```
```

0 comments on commit 0232e7a

Please sign in to comment.