UNPKG

synapse-react-client

Version:

[![npm version](https://badge.fury.io/js/synapse-react-client.svg)](https://badge.fury.io/js/synapse-react-client) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettie

32 lines (31 loc) 940 B
import l from "./useGridPresignedUrl.js"; import { DataGridWebSocket as c } from "../../components/DataGrid/DataGridWebSocket.js"; import { useMutation as m } from "@tanstack/react-query"; import { useState as d, useCallback as f } from "react"; function p(n) { const { mutateAsync: o } = l(), [i, r] = d(null), s = f(() => { r(null); }, []); return { ...m({ retry: 5, retryDelay: (e) => Math.min(e > 1 ? 2 ** e * 1e3 : 1e3, 30 * 1e3), mutationFn: async ({ replicaId: e, sessionId: u, websocketOptions: a }) => { if (!e) throw new Error("replicaId is required"); const t = await o({ replicaId: e, sessionId: u }); return r(t), new c({ replicaId: e, url: t, ...a || {} }); }, ...n }), presignedUrl: i, clearPresignedUrl: s }; } export { p as useEstablishWebsocketConnection }; //# sourceMappingURL=useEstablishWebsocketConnection.js.map