8000 docs: improve function bindings documentation with examples by braden-w · Pull Request #16310 · sveltejs/svelte · GitHub
[go: up one dir, main page]

Skip to content

docs: improve function bindings documentation with examples #16310

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

braden-w
Copy link
@braden-w braden-w commented Jul 7, 2025

This pull request significantly enhances the documentation for the createSubscriber function, a crucial but under-documented part of Svelte 5's reactivity system. Key improvements include:

  1. Clearer Opening Description: Rewritten in natural language to immediately explain createSubscriber as a "bridge" between external events and Svelte's reactivity.

  2. Comprehensive Examples: Added three detailed examples demonstrating common patterns: a generic reactive utility, a class-based MediaQuery integration, and a function-based mousePosition tracker. These highlight proper Svelte 5 patterns and essential cleanup.

  3. Improved JSDoc Structure: Enhanced with clear @param tags, multiple @example sections, a dedicated "Implementation Details" section, and a practical "When to use" guide.

This enhancement makes createSubscriber more intuitive and helps developers confidently integrate external APIs, ensuring proper usage to prevent issues such as memory leaks. Hopefully, we can further clarify one of Svelte 5's powerful features!

Copy link
changeset-bot bot commented Jul 7, 2025

⚠️ No Changeset found

Latest commit: 15fea4c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@svelte-docs-bot
Copy link

- Improved documentation clarity with natural language explanations
- Added clear generic pattern example showing the subscription model
- Enhanced MediaQuery and mouse position examples with proper formatting
- Explained internal mechanism and key characteristics
- Added guidance on when to use createSubscriber
@braden-w braden-w force-pushed the docs/improve-createSubscriber-documentation branch from 69c2f9f to 15fea4c Compare July 7, 2025 05:04
Copy link
Contributor
@Ocean-OS Ocean-OS left a comment

Choose a reason for hiding this comment

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

This looks nice, but seems like too much text for a JSDoc description. Could you move some of it to the documentation?

Copy link
Contributor
github-actions bot commented Jul 7, 2025

Playground

pnpm add https://pkg.pr.new/svelte@16310

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.

2 participants
0