Skip to content

Commit

Permalink
expand readme
Browse files Browse the repository at this point in the history
  • Loading branch information
stancl committed Jul 10, 2021
1 parent c58681a commit 5a168be
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Currently it's only possible to use this library using a `<script type="module">

```html
<script type="module">
import { createApp } from 'todo'
import { createApp } from 'https://unpkg.com/@archtechx/livewire-petite-vue'
window.addEventListener('livewire:load', () => {
createApp().mount()
Expand All @@ -20,7 +20,7 @@ The imported `createApp` automatically includes a bit of global state and a `v-l

```html
<script type="module">
import { state, directive } from 'todo'
import { state, directive } from 'https://unpkg.com/@archtechx/livewire-petite-vue'
import { createApp } from 'https://unpkg.com/petite-vue?module'
window.addEventListener('livewire:load', () => {
Expand Down Expand Up @@ -53,6 +53,20 @@ If you'd like to defer value changes, i.e. have reactive state in Vue but only u
<div v-livewire.defer="['messages']" v-scope="{ messages: {} }">
```

After your bindings are configured, you can simply update state and the changes will sync between Vue and Livewire. Any changes done in Livewire will be reflected in Vue, and any changes done in Vue (e.g. via `v-model` inputs) will be reflected in Livewire.

That's the state. But Livewire can also call methods.

For that, you can simply use the `wire` proxy in your component's state:

```html
<button type="button" @click="wire.send(id)">
Send
</button>
```

If the methods return a value, you can do something like `await wire.foo('bar')`.

```html
<div v-livewire="['messages']" v-scope="{ messages: {}, foo: 'bar' }">
You can use Vue-only state in the component: {{ foo }}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@archtechx/livewire-petite-vue",
"version": "0.1.0",
"version": "0.1.1",
"description": "petite-vue driver for Livewire",
"files": [
"src/index.js"
Expand Down

0 comments on commit 5a168be

Please sign in to comment.