kkinder / puepy

Python+Webassembly Frontend Framework via PyScript
https://puepy.dev
Apache License 2.0
193 stars 8 forks source link

The slots example does not fire the my_custom_event #9

Closed Code4SAFrankie closed 2 months ago

Code4SAFrankie commented 2 months ago

The example on https://docs.puepy.dev/components.html#slots does not fire the my_custom_event, but instead writes to the console: Triggering event with underscores. Did you mean dashes?: my_custom_event

kkinder commented 2 months ago

Does it work on PyScript.com when you run it? See here: https://kkinder.pyscriptapps.com/puepy-tutorial/latest/tutorial/06_components/index.html

Code4SAFrankie commented 2 months ago

Yes

kkinder commented 2 months ago

You're right, there was an issue a while back I did fix, where PuePy's event system was using underscores, but most other projects were using hyphens, so I updated PuePy but neglected to update the docs. I fixed them now.

Your tickets are a good reminder of why we need tests for what's in the docs, not just the samples. Thanks; should be fixed now. You just change "my_custom_event" to "my-custom-event" here:

    def on_button_click(self, event):
        self.trigger_event("my-custom-event", detail={"type": self.type})