All skills
using-kea-disposables
Register timers and event listeners in a kea logic through cache.disposables.add so cleanup runs automatically.
- Part of PostHog/posthog
- 146 installs
- Developer Tools · Frontend
When to use it
You're writing a kea logic that sets up a setInterval, setTimeout, or window listener and you're about to add a matching beforeUnmount to clear it.
For example
You say
In our kea logic I added a setInterval in afterMount that polls team data every 30s, plus a beforeUnmount that clears it. Convert this to use kea disposables so it cleans up on unmount and pauses when the tab is hidden.
You get
- Updated logic file
- Removed beforeUnmount block
How it works
- Named keys let you call dispose(key) to stop a timer or listener early on a state change.
- pauseOnPageHidden defaults to true; opt out for storage, online/offline, message, or visibilitychange listeners.
- The disposables builder replaces afterMount for resources that live as long as the logic.
More Frontend skills
See all- bmad-agent-ux-designer17.7kActs as Sally the UX designer and UI specialist for design guidance.
- daisyui13.9kWrites HTML and JSX markup using daisyUI components whenever you build a page or interface.
- nextjs-developer6.2kBuilds Next.js apps with App Router, server components, route handlers, middleware and Vercel deployment.
- react-expert5.9kCreates React components and hooks, fixes rendering issues and handles state, forms and performance.
Also in this pack
- react-doctor511Diagnoses and fixes React codebase health issues, including performance problems, security gaps and code quality.
- hogli267Explains the PostHog developer CLI and repo tooling for running, building, testing, and linting.
- clickhouse-migrations266Writes and modifies ClickHouse database migrations following project rules.
- survey-sdk-audit255Audits survey SDK features and version requirements, then implements survey changes across backend, UI, and SDKs.