Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions docs/content/2.module/0.guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ Set `category` (`app`, `analyze`, `server`, `modules`, `documentation`, `advance
`register()` returns a handle to patch the entry later, for example to show a badge:

```ts
const entry = ctx.docks.register({ id: 'my-module', /* ... */ })
entry.update({ badge: '3' })
onDevtoolsReady((ctx) => {
const entry = ctx.docks.register({ id: 'my-module', /* ... */ })
entry.update({ badge: '3' })
})
```

Learn more about [DevTools Utility Kit](/module/utils-kit).
Expand Down Expand Up @@ -112,9 +114,11 @@ export default defineNuxtModule({
},
})

// call client RPC functions
// since there might be multiple clients connected, `broadcast` calls all of them
rpc.broadcast({ method: 'show-notification', args: ['Hello from My Module!'], event: true })
// call client RPC functions when something changes; `broadcast` reaches
// every connected client (none are connected yet when this hook runs)
nuxt.hook('builder:watch', (_event, path) => {
rpc.broadcast({ method: 'show-notification', args: [`${path} changed`], event: true })
})
})
},
})
Expand Down
Loading