Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Event forwarding not working #124

Closed
RedHatter opened this issue Mar 5, 2020 · 6 comments
Closed

Event forwarding not working #124

RedHatter opened this issue Mar 5, 2020 · 6 comments

Comments

@RedHatter
Copy link

Event forwarding on native components doesn't seem to work. In the example below Button should be forwarding the tap event so that App can listen to it but when the button is tapped nothing happens.

Button.svelte

<button on:tap>Tap me</button>

App.svelte

<page>
    <Button on:tap={() => console.log('tap')} />
</page>

<script>
    import Button from './Button.svelte'
</script>
@halfnelson
Copy link
Owner

Thanks for the report 👍
This has been fixed and deployed in svelte native 0.8.1

The problem was nativescript events use "event.eventName" to dispatch, but svelte uses "event.type". I had a workaround for direct listeners, but the bubble logic wasn't patched.

@RedHatter
Copy link
Author

@halfnelson This still seems to be not working

@halfnelson
Copy link
Owner

I can't seem to reproduce with the latest version.
https://svelte-native.technology/repl?version=3.19.2&gist=3fff1d0f0a1a4722845ae6183cfbd081

Do you have a way to reproduce the problem?

@RedHatter
Copy link
Author

Oddly enough looks like it does work for button but, as you'll see below, there are cases it doesn't. For example tapping on a button.
repl
(Note: I tested locally as the repel just hangs on "Connecting...")

@halfnelson
Copy link
Owner

I gave it a good dig, and found that gestureEvents on views have their own dispatch mechanism and don't use observable.notify (which I was monkey patching), I found a more elegant way to address this and shipped 0.8.2 . Your example now works :)

@RedHatter
Copy link
Author

It does appear to be working. Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants