reanimate
import { reanimate } from "https://gitlab.com/soapbox-pub/nostr-machina/-/raw/main/mod.ts";
Keep the WebSocket connected. When closed, a new socket is created.
By default, it uses exponential backoff with a 1 second delay.
You can change this behavior by passing in a backoff
function and delay
value.
@example
const socket = new WebSocket('wss://example.com');
reanimate(socket, (nextsocket) => {
// socket is reanimated
handleSocket(socket);
});
function reanimate(
socket: WebSocket,
cb: (socket: WebSocket) => unknown,
opts?: ReanimateOpts,
): void;