mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-19 16:41:34 +03:00
b95319bd74
* feat(tauri.js) improve api module with type defs for each API function * chore(tauri) move endpoint specific modules * refactor(tauri) move tcp mod to tauri_api * feat(tauri) improve readDir signature, API features as kebab-case names * fix(tauri) make event's payload optional * feat(tauri) if invoke_handler fails, console.error the error message * chore(api) improve JSDoc * chore(tauri.js) update template * chore(tauri) delete empty mod * fix(tauri) tests and example with latest API signature
35 lines
627 B
JavaScript
35 lines
627 B
JavaScript
import tauri from './tauri'
|
|
|
|
/**
|
|
* The event handler callback
|
|
* @callback eventCallback
|
|
* @param {object} event
|
|
* @param {string} event.type
|
|
* @param {any} [event.payload]
|
|
*/
|
|
|
|
/**
|
|
* listen to an event from the backend
|
|
*
|
|
* @param {string} event the event name
|
|
* @param {eventCallback} handler the event handler callback
|
|
*/
|
|
function listen (event, handler) {
|
|
tauri.listen(event, handler)
|
|
}
|
|
|
|
/**
|
|
* emits an event to the backend
|
|
*
|
|
* @param {string} event the event name
|
|
* @param {string} [payload] the event payload
|
|
*/
|
|
function emit (event, payload) {
|
|
tauri.emit(event, payload)
|
|
}
|
|
|
|
export {
|
|
listen,
|
|
emit
|
|
}
|