You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Projections to select desired fields from documents and operations
28
28
- Middleware for implementing access control and custom extensions
29
29
- Ideal for use in browsers or on the server
30
-
- Reconnection of document and query subscriptions
31
30
- Offline change syncing upon reconnection
32
31
- In-memory implementations of database and pub/sub for unit testing
33
32
33
+
### Reconnection
34
+
35
+
**TLDR**
36
+
```javascript
37
+
constWebSocket=require('reconnecting-websocket');
38
+
var socket =newWebSocket('ws://'+window.location.host);
39
+
var connection =newsharedb.Connection(socket);
40
+
```
41
+
42
+
The native Websocket object that you feed to ShareDB's `Connection` constructor **does not** handle reconnections.
43
+
44
+
The easiest way is to give it a WebSocket object that does reconnect. There are plenty of example on the web. The most important thing is that the custom reconnecting websocket, must have the same API as the native rfc6455 version.
45
+
46
+
In the "textarea" example we show this off using a Reconnecting Websocket implementation from [https://github.com/pladaria/reconnecting-websocket](reconnecting-websocket).
0 commit comments