|
3 | 3 | This is a reverse chronological list of the major TinyBase releases, with |
4 | 4 | highlighted features. |
5 | 5 |
|
| 6 | +## v5.1 |
| 7 | + |
| 8 | +This release lets you persist data on a server using the createWsServer |
| 9 | +function. This makes it possible for all clients to disconnect from a path, but, |
| 10 | +when they reconnect, for the data to still be present for them to sync with. |
| 11 | + |
| 12 | +This is done by passing in a second argument to the createWsServer function that |
| 13 | +creates a Persister instance (for which also need to create or provide a |
| 14 | +MergeableStore) for a given path: |
| 15 | + |
| 16 | +```js |
| 17 | +import {WebSocketServer} from 'ws'; |
| 18 | +import {createFilePersister} from 'tinybase/persisters/persister-file'; |
| 19 | +import {createMergeableStore} from 'tinybase'; |
| 20 | +import {createWsServer} from 'tinybase/synchronizers/synchronizer-ws-server'; |
| 21 | + |
| 22 | +const persistingServer = createWsServer( |
| 23 | + new WebSocketServer({port: 8051}), |
| 24 | + (pathId) => createFilePersister(createMergeableStore(), pathId + '.json'), |
| 25 | +); |
| 26 | +``` |
| 27 | + |
| 28 | +This is a very crude (and not production-safe!) example, but demonstrates a |
| 29 | +server that will create a file, based on any path that clients connect to, and |
| 30 | +persist data to it. See the createWsServer function documentation for more |
| 31 | +details. |
| 32 | + |
| 33 | +This implementation is still experimental so please kick the tires! |
| 34 | + |
6 | 35 | ## v5.0 |
7 | 36 |
|
8 | 37 | We're excited to announce this major release for TinyBase! It includes |
@@ -38,8 +67,6 @@ you apply that to (another) store. The merge method is a convenience function to |
38 | 67 | bidirectionally merge two stores together: |
39 | 68 |
|
40 | 69 | ```js |
41 | | -import {createMergeableStore} from 'tinybase'; |
42 | | - |
43 | 70 | const localStore1 = createMergeableStore(); |
44 | 71 | const localStore2 = createMergeableStore(); |
45 | 72 |
|
@@ -74,8 +101,7 @@ MergeableStore objects to be merged together. This can be across a network, |
74 | 101 | using WebSockets, for example: |
75 | 102 |
|
76 | 103 | ```js |
77 | | -import {WebSocketServer, WebSocket} from 'ws'; |
78 | | -import {createWsServer} from 'tinybase/synchronizers/synchronizer-ws-server'; |
| 104 | +import {WebSocket} from 'ws'; |
79 | 105 | import {createWsSynchronizer} from 'tinybase/synchronizers/synchronizer-ws-client'; |
80 | 106 |
|
81 | 107 | // On a server machine: |
|
0 commit comments