Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change on: handlers to reflect svelte 5 updates #624

Open
vexkiddy opened this issue Jan 6, 2025 · 12 comments
Open

change on: handlers to reflect svelte 5 updates #624

vexkiddy opened this issue Jan 6, 2025 · 12 comments

Comments

@vexkiddy
Copy link

vexkiddy commented Jan 6, 2025

In svelte 5 on: handlers have been depreciated, it would be great if the package could be updated to use the new syntax :D

@isaacHagoel
Copy link
Owner

isaacHagoel commented Jan 6, 2025 via email

@vexkiddy
Copy link
Author

vexkiddy commented Jan 7, 2025

hiya, thanks for getting back to me! I guess it really depends if you want to update the entire project to svelte 5 or not. It's a lot cleaner to deal with all the state in svelte 5 and they have changed the way that you emit events to parents. So on:EventHandler is now deprecated, it's more like the below:

Child.svelte

<script>
  let { onYes, onNo } = $props();
</script>

<button onclick={onYes}>YES</button>
<button onclick={onNo}>NO</button>

Parent.svelte

<script>
  import AnswerButton from "./AnswerButton.svelte";
  let isHappy = $state(true);
  
function onAnswerNo() {
    isHappy = false;
  }

  function onAnswerYes() {
    isHappy = true;
  }
</script>

<p>Are you happy?</p>
<AnswerButton onYes={onAnswerYes} onNo={onAnswerNo} />
<p style="font-size: 50px;">{isHappy ? "😀" : "😥"}</p>

@isaacHagoel
Copy link
Owner

isaacHagoel commented Jan 7, 2025 via email

@vexkiddy
Copy link
Author

vexkiddy commented Jan 7, 2025

ah ok, not to worry then, though just out of interest, do you have any plans to port the repo to svelte 5 in the future ?

@isaacHagoel
Copy link
Owner

isaacHagoel commented Jan 7, 2025 via email

@vexkiddy
Copy link
Author

vexkiddy commented Jan 7, 2025

It's just currently IDE's will complain as the syntax is not svelte 5. You also have much better state management in svelte 5 than you do in previous versions, allowing you to have state in normal js files using the .svelte.js file extension.

CleanShot 2025-01-07 at 22 41 17@2x

@isaacHagoel
Copy link
Owner

isaacHagoel commented Jan 7, 2025 via email

@vexkiddy
Copy link
Author

vexkiddy commented Jan 8, 2025

no, you'll still need to send it from the child. I'd really recommend having a proper look at all the new svelte 5 stuff. Either way, as you say it works with older projects, its just the IDE will complain if you're in strict runes mode.

@isaacHagoel
Copy link
Owner

isaacHagoel commented Jan 8, 2025 via email

@digitalit
Copy link

So is it okay to start using this in svelte 5 or should i wait?

@isaacHagoel
Copy link
Owner

isaacHagoel commented Jan 12, 2025 via email

@digitalit
Copy link

It's okay. It will work fine

On Sun, Jan 12, 2025, 19:38 Peter Carlsson @.> wrote: So is it okay to start using this in svelte 5 or should i wait? — Reply to this email directly, view it on GitHub <#624 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE4OZC3QFIQF3EBVX2OID7D2KISYVAVCNFSM6AAAAABUWKYVYCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKOBVGY2DEOJQHA . You are receiving this because you commented.Message ID: @.>

Sweet. Wow, fastest issue respons ever :)

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

No branches or pull requests

3 participants