Skip to content

API reference / @chanx-js/client / svelte / createChannel

Function: createChannel() ​

ts
function createChannel<D>(descriptor, options?): ChannelStore<ToServerOf<D>, ToClientOf<D>>;

Defined in: packages/client/src/svelte/index.ts:87

Open (or join) a channel as a store: $chat.status, $chat.lastMessage.

Inside a component it connects on mount and closes on destroy. Outside one it connects at once; call close() yourself. Options are read once: for new params, create a new store.

Type Parameters ​

Type Parameter
D extends ChannelDescriptor<any, any, any, any>

Parameters ​

ParameterType
descriptorD
optionsControllerOptions<AddressOf<D>, ToClientOf<D>> & object

Returns ​

ChannelStore<ToServerOf<D>, ToClientOf<D>>

MIT licensed