Svelte - Event dispatching (this is useful!)

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 ก.พ. 2025

ความคิดเห็น • 14

  • @dominigon
    @dominigon 5 ปีที่แล้ว +7

    I think you need to talk about event forwarding just by writing on:event in child component, also more about event modifiers

    • @SvelteMastery
      @SvelteMastery  5 ปีที่แล้ว

      ah you're right, i forgot to mention how to do event forwarding! But here's a video I have on event modifiers th-cam.com/video/Sj5Dskbphnk/w-d-xo.html

  • @yt-sh
    @yt-sh 5 ปีที่แล้ว

    Nice Video, looking forward for more such content!

  • @etylocus
    @etylocus 4 ปีที่แล้ว +3

    The way you start (By adding an event dispatcher) is not the easiest way.
    For a simple component as the button you are using is, just adding on:click will handle the even dispatching just fine.
    Dispatchers are for more complicated stuff.

    • @SvelteMastery
      @SvelteMastery  4 ปีที่แล้ว +1

      True, maybe I hadn’t learned about event forwarding yet

  • @cyrusbesabella5938
    @cyrusbesabella5938 4 ปีที่แล้ว +1

    lol i love the smiley sign up!! thanks

  • @PB72UK
    @PB72UK 4 ปีที่แล้ว +1

    Just use preventDefault, if you don't want the form to submit .. no need to use a different type of button

    • @SvelteMastery
      @SvelteMastery  4 ปีที่แล้ว +1

      True, that’s one way to do it!

  • @literallybiras
    @literallybiras 5 ปีที่แล้ว +1

    good content

  • @duechilidance5388
    @duechilidance5388 4 ปีที่แล้ว

    Thanks great overview
    I am really interested in svelte, at the moment I am creating a components based app in vanilla javascript to really understand the underlying concepts.
    Du you have an suggestion how to write a template parser like createEventDispatcher, so you can connect attribute-like statements like on:click which execute functions which are not oo the window object?

    • @SvelteMastery
      @SvelteMastery  4 ปีที่แล้ว

      Hmm that sounds hard. Sorry, i don’t have any ideas. I’m curious, why do you want to do that?

  • @X1Zeth2X
    @X1Zeth2X 5 ปีที่แล้ว +1

    Possibly make a TypeScript guide?

    • @SvelteMastery
      @SvelteMastery  5 ปีที่แล้ว +1

      here you go th-cam.com/video/tFeJKQdzzvo/w-d-xo.html

    • @X1Zeth2X
      @X1Zeth2X 5 ปีที่แล้ว

      @@SvelteMastery Nice, we appreciate your work my friend.