0Pricing
Sveltejs Academy · Lesson

Avoiding Stale Closures

Understand when closures capture old values and how to prevent bugs.

What is a Closure

A closure captures variables from its enclosing scope. The values it sees are those at creation time.

Stale Captures

If you create a function that captures a variable, later changes to that variable may not be visible inside.

All lessons in this course

  1. Reactive Statements: $: block
  2. Reactive Dependencies and Ordering
  3. When to Use Stores vs Local State
  4. Avoiding Stale Closures
← Back to Sveltejs Academy