@replit/river
Advanced tools
Comparing version 0.10.10 to 0.10.11
@@ -32,8 +32,9 @@ import WebSocket from 'isomorphic-ws'; | ||
/** | ||
* Creates a new WebSocketTransport instance. | ||
* Creates a new WebSocketClientTransport instance. | ||
* @param wsGetter A function that returns a Promise that resolves to a WebSocket instance. | ||
* @param clientId The ID of the client using the transport. | ||
* @param sessionId The ID of the client using the transport. This should be unique per session. | ||
* @param serverId The ID of the server this transport is connecting to. | ||
* @param providedOptions An optional object containing configuration options for the transport. | ||
*/ | ||
constructor(wsGetter: () => Promise<WebSocket>, clientId: TransportClientId, serverId: TransportClientId, providedOptions?: Partial<Options>); | ||
constructor(wsGetter: () => Promise<WebSocket>, sessionId: TransportClientId, serverId: TransportClientId, providedOptions?: Partial<Options>); | ||
createNewConnection(to: string, attempt?: number): Promise<void>; | ||
@@ -40,0 +41,0 @@ close(): Promise<void>; |
import { | ||
WebSocketClientTransport | ||
} from "../../../chunk-FTVAZZ6B.js"; | ||
} from "../../../chunk-KW5VFJRN.js"; | ||
import "../../../chunk-L7D75G4K.js"; | ||
@@ -5,0 +5,0 @@ import "../../../chunk-R6H2BIMC.js"; |
@@ -7,3 +7,3 @@ import { | ||
WebSocketClientTransport | ||
} from "../chunk-FTVAZZ6B.js"; | ||
} from "../chunk-KW5VFJRN.js"; | ||
import { | ||
@@ -10,0 +10,0 @@ WebSocketServerTransport |
{ | ||
"name": "@replit/river", | ||
"description": "It's like tRPC but... with JSON Schema Support, duplex streaming and support for service multiplexing. Transport agnostic!", | ||
"version": "0.10.10", | ||
"version": "0.10.11", | ||
"type": "module", | ||
@@ -6,0 +6,0 @@ "exports": { |
@@ -92,2 +92,3 @@ # river - Streaming Remote Procedure Calls | ||
import { createClient } from '@replit/river'; | ||
import type ServiceSurface from './server'; | ||
@@ -122,2 +123,20 @@ const websocketUrl = `ws://localhost:3000`; | ||
To listen for connection status changes, | ||
```ts | ||
transport.addEventListener('connectionStatus', (evt) => { | ||
if (evt.status === 'connect') { | ||
// do something | ||
} else if (evt.status === 'disconnect') { | ||
// do something else | ||
} | ||
}); | ||
``` | ||
> [!note] WebSocket connection behaviour | ||
> WebSocket is an idle protocol. This means that when the underlying connection drops, the WebSocket | ||
> may still think it is still connected (e.g. turning off the network via devtools). | ||
> You can use `window.addEventListener('online', ...);` and `window.addEventListener('offline', ...);` to | ||
> know if you need to recreate the transport. | ||
### Further examples | ||
@@ -124,0 +143,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
295538
8095
156