2020-03-10 00:44:19 +03:00
|
|
|
import tauri from './tauri'
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The event handler callback
|
2020-04-03 19:30:26 +03:00
|
|
|
* @callback EventCallback
|
|
|
|
* @param {Object} event
|
|
|
|
* @param {String} event.type
|
2020-03-10 00:44:19 +03:00
|
|
|
* @param {any} [event.payload]
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* listen to an event from the backend
|
|
|
|
*
|
2020-04-03 19:30:26 +03:00
|
|
|
* @param {String} event the event name
|
|
|
|
* @param {EventCallback} handler the event handler callback
|
2020-03-10 00:44:19 +03:00
|
|
|
*/
|
|
|
|
function listen (event, handler) {
|
|
|
|
tauri.listen(event, handler)
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* emits an event to the backend
|
|
|
|
*
|
2020-04-03 19:30:26 +03:00
|
|
|
* @param {String} event the event name
|
|
|
|
* @param {String} [payload] the event payload
|
2020-03-10 00:44:19 +03:00
|
|
|
*/
|
|
|
|
function emit (event, payload) {
|
|
|
|
tauri.emit(event, payload)
|
|
|
|
}
|
|
|
|
|
|
|
|
export {
|
|
|
|
listen,
|
|
|
|
emit
|
|
|
|
}
|