Skip to content

Conversation

@0xsatoshi99
Copy link
Contributor

Adds comprehensive SharedWorkerGlobalScope example. Fixes #160

Adds comprehensive example demonstrating SharedWorkerGlobalScope interface,
addressing the 2-year-old request in issue mdn#160.

Features:
- Complete SharedWorkerGlobalScope demonstration
- Shows 'name' property access
- Demonstrates 'onconnect' event handler
- Connection tracking across multiple clients
- Message broadcasting between clients
- Connection management and cleanup

Files Added:
- index.html (60 lines) - Interactive UI with 2 clients
- worker.js (100 lines) - SharedWorker with GlobalScope features
- main.js (120 lines) - Client-side logic
- style.css (130 lines) - Styling
- README.md (50 lines) - Documentation

Key Demonstrations:
1. SharedWorkerGlobalScope.name property
2. SharedWorkerGlobalScope.onconnect handler
3. Multiple client connections to same worker
4. Shared state across browser tabs
5. Message broadcasting
6. Connection lifecycle management

The example includes:
✅ Two interactive clients on same page
✅ Real-time connection counting
✅ Message broadcasting between clients
✅ Comprehensive comments explaining SharedWorkerGlobalScope
✅ Instructions to test across multiple tabs
✅ Detailed README with MDN links

This provides developers with a practical, working example of
SharedWorkerGlobalScope that can be tested immediately.

Fixes mdn#160
@0xsatoshi99 0xsatoshi99 requested a review from a team as a code owner October 31, 2025 03:37
@0xsatoshi99 0xsatoshi99 requested a review from pransh15 October 31, 2025 03:37
@pransh15 pransh15 requested review from dipikabh and removed request for pransh15 October 31, 2025 11:28
@pepelsbey pepelsbey requested review from pepelsbey and removed request for dipikabh November 3, 2025 14:25
@0xsatoshi99 0xsatoshi99 closed this Nov 6, 2025
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.

Add example for SharedWorkerGlobalScope

1 participant