Skip to content

Commit

Permalink
Merge branch 'master' into feat-style-object
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoDF committed Mar 22, 2020
2 parents b119a2a + b6e07b2 commit d741b2b
Show file tree
Hide file tree
Showing 13 changed files with 9,076 additions and 8,320 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ There are 13 directives available to you:
| [`x-transition`](#x-transition) |
| [`x-cloak`](#x-cloak) |

And 5 magic properties:
And 6 magic properties:

| Magic Properties
| --- |
Expand All @@ -111,6 +111,7 @@ And 5 magic properties:
| [`$event`](#event) |
| [`$dispatch`](#dispatch) |
| [`$nextTick`](#nexttick) |
| [`$watch`](#watch) |


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

`$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.

---

### `$watch`
**Example:**
```html
<div x-data="{ open: false }" x-init="$watch('open', value => console.log(value))">
<button @click="open = ! open">Toggle Open</button>
</div>
```

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.

## v3 Roadmap
* Move from `x-ref` to `ref` for Vue parity

Expand Down
Loading

0 comments on commit d741b2b

Please sign in to comment.