mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-11 10:43:31 +02:00
refactor(core): refactor and fix event system following multiwebview support (#8621)
* clippy * refactor(core): refactor and fix event system following multiwebview support * update documentation * update js docs * lint * clippy * update multiwindow example [skip ci] * enhance event tests * fix example * Update .changes/tauri-event-after-multiwebview.md Co-authored-by: Lucas Nogueira <118899497+lucasfernog-crabnebula@users.noreply.github.com> * fix tests * add diagram * Add `App/AppHandle` even target * Discard changes to examples/api/src-tauri/tauri-plugin-sample/permissions/schemas/schema.json * revert accidental changes * regenerate schemas * fix doctests * add helper methods * update docs * update api * update docs [skip ci] * update docs [skip ci] --------- Co-authored-by: Lucas Nogueira <lucas@tauri.app> Co-authored-by: Lucas Nogueira <118899497+lucasfernog-crabnebula@users.noreply.github.com>
This commit is contained in:
@@ -24,11 +24,10 @@
|
||||
const container = document.getElementById('container')
|
||||
|
||||
function createWindowMessageBtn(label) {
|
||||
const webview = WebviewWindow.getByLabel(label)
|
||||
const button = document.createElement('button')
|
||||
button.innerText = 'Send message to ' + label
|
||||
button.addEventListener('click', function () {
|
||||
webview.emit('clicked', 'message from ' + windowLabel)
|
||||
appWindow.emitTo(label, 'clicked', 'message from ' + windowLabel)
|
||||
})
|
||||
container.appendChild(button)
|
||||
}
|
||||
@@ -67,7 +66,7 @@
|
||||
globalMessageButton.innerHTML = 'Send global message'
|
||||
globalMessageButton.addEventListener('click', function () {
|
||||
// emit to all windows
|
||||
window.__TAURI__.event.emit('clicked', 'message from ' + windowLabel)
|
||||
appWindow.emit('clicked', 'message from ' + windowLabel)
|
||||
})
|
||||
container.appendChild(globalMessageButton)
|
||||
|
||||
@@ -82,4 +81,4 @@
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user