Skip to content

Commit d741b2b

Browse files
committed
Merge branch 'master' into feat-style-object
2 parents b119a2a + b6e07b2 commit d741b2b

File tree

13 files changed

+9076
-8320
lines changed

13 files changed

+9076
-8320
lines changed

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ There are 13 directives available to you:
102102
| [`x-transition`](#x-transition) |
103103
| [`x-cloak`](#x-cloak) |
104104

105-
And 5 magic properties:
105+
And 6 magic properties:
106106

107107
| Magic Properties
108108
| --- |
@@ -111,6 +111,7 @@ And 5 magic properties:
111111
| [`$event`](#event) |
112112
| [`$dispatch`](#dispatch) |
113113
| [`$nextTick`](#nexttick) |
114+
| [`$watch`](#watch) |
114115

115116

116117
### Directives
@@ -520,6 +521,18 @@ You can also use `$dispatch()` to trigger data updates for `x-model` bindings. F
520521

521522
`$nextTick` is a magic property that allows you to only execute a given expression AFTER Alpine has made its reactive DOM updates. This is useful for times you want to interact with the DOM state AFTER it's reflected any data updates you've made.
522523

524+
---
525+
526+
### `$watch`
527+
**Example:**
528+
```html
529+
<div x-data="{ open: false }" x-init="$watch('open', value => console.log(value))">
530+
<button @click="open = ! open">Toggle Open</button>
531+
</div>
532+
```
533+
534+
You can "watch" a component property with the `$watch` magic method. In the above example, when the button is clicked and `open` is changed, the provided callback will fire and `console.log` the new value.
535+
523536
## v3 Roadmap
524537
* Move from `x-ref` to `ref` for Vue parity
525538

0 commit comments

Comments
 (0)