Skip to content

Archive

State Management

3 articles
Software Engineering 15 Sep 2026 7 min read

Generation Counters Reject Stale Async Results

An asynchronous operation can start first and finish last. If every completion writes into the same state slot, completion order becomes state order even when the application intended request order to define authority. This race appears without shared-memory threads. Two network requests, background computations, database queries, or worker messages can overlap through an event loop and return in the opposite order from their initiation. The older result is not necessarily incorrect data. It is stale because a later request has superseded the state transition that originally authorized it.

Software Engineering 15 Sep 2026 7 min read

Connection Pools Turn Session State Into Shared State

A database connection pool reuses physical sessions across many logical borrowers. That reuse changes the lifetime of session-scoped state. A setting applied by one request can outlive the request itself because returning a connection to the pool usually ends only the borrower’s access to that connection, not the database session behind it. This distinction matters whenever application code changes properties that belong to the session rather than to a single statement or transaction. Transaction isolation, read-only mode, schema selection, session variables, advisory locks, temporary objects, prepared statements, and database-specific configuration can all have lifetimes that differ from the lexical scope of application code.

JavaScript 11 Sep 2025 3 min read

Building a Todo List with Stores in SvelteKit

Svelte stores provide a simple way to share reactive state across components. In this tutorial, we will build a small Todo List with: Adding tasks Marking tasks complete Editing tasks Deleting tasks Task statistics A live clock The example uses Svelte + TypeScript and the classic Svelte store APIs. 1. Define the Task Type Create src/lib/types/task.ts: export interface Task { id: number; title: string; done: boolean; } Each task has: