Skip to content

Svelte 5 Framework Binding for @arkosjs/websockets-client #258

Description

@Uanela

Before All

  1. Core Reference - Contributing Framework Bindings

  2. Base branch: feat/websockets-client

  3. Reference Implementation: React Bindings

  4. Implemented Projects: Tic Tac Toe Real Time


Summary

Create a Svelte 5 adapter package @arkosjs/svelte-websockets that wraps @arkosjs/websockets-client with Svelte 5's reactivity primitives (runes, stores, or both).

Required Files (Only Example)

integrations/svelte-websockets/
├── src/
│   ├── context.ts          # Context provider (initArkosClient, getArkosClient)
│   ├── use-gateway.ts      # useGateway composable
│   └── index.ts            # Public exports
├── ArkosProvider.svelte    # Provider component
├── package.json
├── tsconfig.json
└── README.md

API Contract (must match React version idiomatically)

<!-- Root layout -->
<ArkosProvider manager={manager}>
  <App />
</ArkosProvider>
<script>
  const chat = useGateway("/chat");
  chat.on("receive_message", (data) => { ... });
  
  const sendMessage = chat.useEmit("send_message");
  sendMessage.emit({ text: "hello" }, { ack: true });
</script>

<div>
  Status: {$chat.status}
  User: {$chat.user}
  {#if $sendMessage.loading} Sending... {/if}
</div>

What needs testing (since this code is AI-generated)

  • Provider cleanup on destroy (client.destroy() called)
  • Listener cleanup on component unmount (no memory leaks)
  • Re-subscription when namespace changes
  • loading flips correctly on ack emit
  • status updates reactively on disconnect/reconnect
  • user populates when server emits "authenticated"
  • Works with Svelte 5 runes mode

Deliverables

  • Working Svelte 5 adapter package
  • Minimal example app demonstrating connect → emit → receive
  • Tests (if framework allows)

Note: The code in the contributing document is AI-generated and untested by a real framework user. Your contribution will validate and fix it. Open PR to feat/websockets-client and create your branch from it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions