Events
Events are important for the inner workings of your App.
Sometimes you need an event bus or a publish/subscribe channel. Quasar provides this out of the box:
Essentially, Events is just a Vue event bus that you can use throughout your App. If you know how to use Vue events, then you’re all set to go.
Methods
Registering for an Event
Events.$on(String eventName, Function callback)
Example:
Removing Callback for an Event
Events.$off(String eventName [, Function callback])
Registering a Callback to Be Run Only Once
Events.$once(String eventName, Function callback)
Sometimes you need to trigger a callback only once. Example:
Triggering an Event
Events.$emit(String eventName [, Anything *arg])
Example:
Quasar Events List
There are some events emitted by Quasar already that you can hook into.
Global Events
Event Name | Description |
---|---|
app:error | Triggered for any Javascript error. See parameters below. |
Parameter supplied by app:error
app:error
event is triggerd with one parameter, an Object containing the following properties:
Property Name | Type | Description |
---|---|---|
message | String | Error message |
source | String | URL of the script where the error was raised |
lineno | Number | Line number where error was raised |
colno | Number | Column number for the line where the error occurred |
error | Object | Error Object containing amongst other things the stack trace |
App Visibility
Event Name | Parameters | Description |
---|---|---|
app:visibility | (String) state | App got focus if state is visible or lost focus if state is hidden |
Read more about it here.
Toast
Event Name | Parameters | Description |
---|---|---|
app:notify | (String) html | Is triggered whenever a Toast is displayed. |
Read more about it here.
Loading
Event Name | Parameters | Description |
---|---|---|
app:loading | (Boolean) status | Triggered when Loading component is displayed (with true as param) or hidden (with false as param). |
Read more about it here.