ThreadRoutingAdapter

Unpublished development API. This package is under development and is not available as a published release.

Binds the active thread to a URL. The default adapter uses window.location and window.history; React Router or Next.js applications can supply one built from their own location and navigation functions.

import type { ThreadRoutingAdapter } from '@threadplane/react/chat';

Declaration

export interface ThreadRoutingAdapter  {
  read(): string | null;
  subscribe(onChange: () => void): () => void;
  write(threadId: string | null, mode: ThreadRoutingWriteMode): void;
}

Members

read · overload 1

The thread id in the current URL, or null for the bare URL.

read(): string | null;

Returns

string | null

subscribe · overload 1

Call onChange when the URL changes outside write, such as back and forward.

subscribe(onChange: () => void): () => void;

Parameters

onChange · required
() => void

Returns

() => void

write · overload 1

Write a thread id (null clears it) to the URL.

write(threadId: string | null, mode: ThreadRoutingWriteMode): void;

Parameters

threadId · required
string | null
mode · required
ThreadRoutingWriteMode

Returns

void