braid-http 0.3.19 → 0.3.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/braid-http-client.js +1 -1
- package/braid-http-server.js +1 -1
- package/package.json +1 -1
- package/readme.md +4 -4
package/braid-http-client.js
CHANGED
|
@@ -229,7 +229,7 @@ async function braid_fetch (url, params = {}) {
|
|
|
229
229
|
|
|
230
230
|
// Now we define the subscription function we just used:
|
|
231
231
|
function start_subscription (cb, error) {
|
|
232
|
-
if (!res.ok)
|
|
232
|
+
if (!res.ok)
|
|
233
233
|
throw new Error('Request returned not ok status:', res.status)
|
|
234
234
|
|
|
235
235
|
if (res.bodyUsed)
|
package/braid-http-server.js
CHANGED
|
@@ -66,7 +66,7 @@ ${patch.content}`
|
|
|
66
66
|
// Deprecated method for legacy support
|
|
67
67
|
function parse_patches (req, cb) {
|
|
68
68
|
parse_update(req, update => {
|
|
69
|
-
if (update.body)
|
|
69
|
+
if (typeof update.body === 'string')
|
|
70
70
|
// Return body as an "everything" patch
|
|
71
71
|
cb([{unit: 'everything', range: '', content: update.body}])
|
|
72
72
|
else
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -103,15 +103,15 @@ async function connect () {
|
|
|
103
103
|
async function connect () {
|
|
104
104
|
try {
|
|
105
105
|
var subscription_iterator = fetch('/chat', {subscribe: true}).subscription
|
|
106
|
-
for await (var
|
|
106
|
+
for await (var update of subscription_iterator) {
|
|
107
107
|
// Updates might come in the form of patches:
|
|
108
|
-
if (
|
|
109
|
-
chat = apply_patches(
|
|
108
|
+
if (update.patches)
|
|
109
|
+
chat = apply_patches(update.patches, chat)
|
|
110
110
|
|
|
111
111
|
// Or complete snapshots:
|
|
112
112
|
else
|
|
113
113
|
// Beware the server doesn't send these yet.
|
|
114
|
-
chat = JSON.parse(
|
|
114
|
+
chat = JSON.parse(update.body)
|
|
115
115
|
|
|
116
116
|
render_stuff()
|
|
117
117
|
}
|