Skip to content

Update tutorial part 1 #274

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

Merged
merged 22 commits into from
Oct 8, 2024
Merged

Update tutorial part 1 #274

merged 22 commits into from
Oct 8, 2024

Conversation

Rich-Harris
Copy link
Member

WIP. Effects is a TODO for now — I think we need it to be in this position, but I'm not sure what a good exercise would be (we should get rid of anything console based since we want to steer people towards $inspect). Struggling to think of examples that shouldn't just be event handlers

Copy link

vercel bot commented Oct 7, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
omnisite ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 8, 2024 1:24pm

@dummdidumm
Copy link
Member

dummdidumm commented Oct 7, 2024

Struggling to think of examples that shouldn't just be event handlers

Some canvas drawing that reacts to some interval at random? Well ... then you could also the interval directly ... huh.

Goes to show that $effect really is an escape hatch 😅

@Rich-Harris
Copy link
Member Author

I added a setInterval exercise for $effect, I think it's as much as we can do.

Controversy alert: I removed the 'Lifecycle' section:

  • While I'm not going to campaign to deprecate onMount, we should really view it as a buggier and less capable $effect. We don't need to scare people who are already familiar with it but I definitely don't think we should be encouraging newcomers to use it. The $effect exercise explains the lifecycle of a dependency-less effect, and I would argue that suffices.
  • beforeUpdate and afterUpdate don't belong in the tutorial since they're deprecated (and the example is silly, it should be using a mutation observer)
  • that just leaves tick, which is a weird thing to have here by itself — it's an advanced topic, so if it belongs anywhere it belongs in part 2

I also removed the 'Stores' section, because similarly we shouldn't be encouraging people to write new store code. This is obviously a little trickier for two reasons...

  • SvelteKit
  • spring and tweened, which don't yet have class-based replacements

...but I still don't think it belongs in part 1, and if we have a store tutorial in part 2 it should be brief.

Things are a bit lopsided now — the advanced section is much longer than the basic section. I think we could move some stuff (actions? etc) from part 2 to part 1.

Copy link
Member

@dummdidumm dummdidumm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff! Agree that it's weird to have tweened etc as store versions without having stores explained anywhere. I also think that it's still worth it to have a section on stores in "advanced svelte" - it doesn't need to be as big as now, it's enough to explain the shorthand and that there's a store package. I'm ok with removing the life cycle part.

<select
value={selected}
on:change={() => (answer = '')}
onchange={() => (answer = '')}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the accompanying md file still has on:change in it

Copy link
Member

@dummdidumm dummdidumm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving, assuming that stores will have a reduced version in the advanced section

@Rich-Harris Rich-Harris merged commit 2d2e6f6 into main Oct 8, 2024
3 checks passed
@Rich-Harris Rich-Harris deleted the tutorial branch October 8, 2024 14:27
@erickpaquin
Copy link

Hi guys. I'm not sure if I should be writing this here or not, but just wanted to let you know that in the "reactivity / state" part of the tutorial, this part doesn't look correct to me :

{count === 1 ? 'time' : 'times'}

it should say this instead :

{count <= 1 ? 'time' : 'times'}

Otherwise the button label prints "times" plural when the button initializes with 0.

Thanks.

@Rich-Harris
Copy link
Member Author

Right, because '0 time' is wrong. You only use the singular when there's 1 of something. That's why it's called 'singular'

@erickpaquin
Copy link

My bad. I didn't know that zero was considered plural in the English language.

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

Successfully merging this pull request may close these issues.

3 participants