Skip to content

Commit e1f7ab0

Browse files
committed
Updating Readme
1 parent 78306cc commit e1f7ab0

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,26 @@ tracker](https://github.com/share/sharedb/issues).
2727
- Projections to select desired fields from documents and operations
2828
- Middleware for implementing access control and custom extensions
2929
- Ideal for use in browsers or on the server
30-
- Reconnection of document and query subscriptions
3130
- Offline change syncing upon reconnection
3231
- In-memory implementations of database and pub/sub for unit testing
3332

33+
### Reconnection
34+
35+
**TLDR**
36+
```javascript
37+
const WebSocket = require('reconnecting-websocket');
38+
var socket = new WebSocket('ws://' + window.location.host);
39+
var connection = new sharedb.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).
47+
48+
49+
3450
## Example apps
3551

3652
[<img src="examples/counter/demo.gif" height="300">

0 commit comments

Comments
 (0)