Add event bus info
This commit is contained in:
parent
a297d77245
commit
7e132b3e2c
@ -53,7 +53,7 @@ The PostalPoint plugin API is a globally-available object.
|
|||||||
* `getPluginFolder(pluginName)`: Get the filesystem path to a plugin's folder.
|
* `getPluginFolder(pluginName)`: Get the filesystem path to a plugin's folder.
|
||||||
If used without arguments, gets the root plugin storage folder.
|
If used without arguments, gets the root plugin storage folder.
|
||||||
* `f7`: The Framework7 app instance for PostalPoint's entire UI, created by `new Framework7()`. See https://framework7.io/docs/app for details. Be very careful.
|
* `f7`: The Framework7 app instance for PostalPoint's entire UI, created by `new Framework7()`. See https://framework7.io/docs/app for details. Be very careful.
|
||||||
|
* `eventbus`: A [Framework7 event bus](https://framework7.io/docs/events#events-bus) that parts of PostalPoint broadcast on. See docs/Events.md for details.
|
||||||
|
|
||||||
#### Barcode
|
#### Barcode
|
||||||
|
|
||||||
|
25
docs/Events.md
Normal file
25
docs/Events.md
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# Event Bus
|
||||||
|
|
||||||
|
Plugins can use `global.apis.eventbus` to receive events when certain actions happen in PostalPoint.
|
||||||
|
|
||||||
|
## Event List
|
||||||
|
|
||||||
|
* `barcodeScanned`: Contents of a barcode that was just scanned.
|
||||||
|
* `browserCloseRequest`: The embedded web browser listens for this event, and closes itself when received.
|
||||||
|
* `browserNavigate`: Contains the URL the embedded web browser just navigated to.
|
||||||
|
* `transactionFinished`: Contains a receipt object of a transaction that was just finalized.
|
||||||
|
|
||||||
|
## Example Code
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
|
||||||
|
// Handle a barcode scan.
|
||||||
|
// Remember that PostalPoint will probably also be doing something in response to the barcode.
|
||||||
|
global.apis.eventbus.on("barcodeScanned", function (barcodedata) {
|
||||||
|
// do something with the barcode
|
||||||
|
});
|
||||||
|
|
||||||
|
// Close the embedded web browser, returning the user to whatever was onscreen before it opened
|
||||||
|
global.apis.eventbus.emit("browserCloseRequest");
|
||||||
|
|
||||||
|
```
|
Loading…
x
Reference in New Issue
Block a user