braid-text 0.2.38 → 0.2.39
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/package.json +1 -1
- package/simpleton-client.js +4 -3
package/package.json
CHANGED
package/simpleton-client.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
// this is for outgoing changes;
|
|
18
18
|
// diff_function = () => ({patches, new_version}).
|
|
19
19
|
//
|
|
20
|
-
function simpleton_client(url, { apply_remote_update, generate_local_diff_update, content_type, on_error }) {
|
|
20
|
+
function simpleton_client(url, { apply_remote_update, generate_local_diff_update, content_type, on_error, on_res }) {
|
|
21
21
|
var peer = Math.random().toString(36).substr(2)
|
|
22
22
|
var current_version = []
|
|
23
23
|
var prev_state = ""
|
|
@@ -34,7 +34,8 @@ function simpleton_client(url, { apply_remote_update, generate_local_diff_update
|
|
|
34
34
|
parents: () => current_version.length ? current_version : null,
|
|
35
35
|
peer,
|
|
36
36
|
signal: ac.signal
|
|
37
|
-
}).then(res =>
|
|
37
|
+
}).then(res => {
|
|
38
|
+
if (on_res) on_res(res)
|
|
38
39
|
res.subscribe(update => {
|
|
39
40
|
// Only accept the update if its parents == our current version
|
|
40
41
|
update.parents.sort()
|
|
@@ -71,7 +72,7 @@ function simpleton_client(url, { apply_remote_update, generate_local_diff_update
|
|
|
71
72
|
prev_state = apply_remote_update(update)
|
|
72
73
|
}
|
|
73
74
|
}, on_error)
|
|
74
|
-
).catch(on_error)
|
|
75
|
+
}).catch(on_error)
|
|
75
76
|
|
|
76
77
|
return {
|
|
77
78
|
stop: async () => {
|