Skip to content

Commit

Permalink
Accept patches from server->client in subs
Browse files Browse the repository at this point in the history
  • Loading branch information
toomim committed Oct 19, 2023
1 parent d0b1a2c commit 80318be
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions client-library.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@
}

// Else, reconnect!
console.log('Reconnecting due to', e)
setTimeout(() => subscribe(key, t),
reconnect_attempts > 0 ? 5000 : 1500)
subscriptions[key].status = 'reconnecting'
Expand Down Expand Up @@ -232,10 +233,17 @@
}

// Return the update
t.return({
key: key,
val: add_prefixes(JSON.parse(new_version.body))
})
if (new_version.body)
// As a snapshot body
t.return({
key: key,
val: add_prefixes(JSON.parse(new_version.body))
})
else if (new_version.patches)
// As a patch
bus.set.fire(key, {patch: new_version.patches.map(
patch => patch.range + ' = ' + patch.content
)})
},
reconnect
)).catch(reconnect)
Expand Down

0 comments on commit 80318be

Please sign in to comment.