Skip to content
Snippets Groups Projects
Commit c9280e2b authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Convert the ListenOn* funcs to be non-async

parent 219a3da6
Branches
Tags
1 merge request!109Project/haven beta
...@@ -420,17 +420,12 @@ func (r *RemoteKV) ListenOnRemoteKey(_ js.Value, args []js.Value) any { ...@@ -420,17 +420,12 @@ func (r *RemoteKV) ListenOnRemoteKey(_ js.Value, args []js.Value) any {
localEvents = args[3].Bool() localEvents = args[3].Bool()
} }
promiseFn := func(resolve, reject func(args ...any) js.Value) {
id, err := r.api.ListenOnRemoteKey(key, version, cb, id, err := r.api.ListenOnRemoteKey(key, version, cb,
localEvents) localEvents)
if err != nil { if err != nil {
reject(exception.NewTrace(err)) exception.ThrowTrace(err)
} else {
resolve(id)
} }
} return id
return utils.CreatePromise(promiseFn)
} }
// ListenOnRemoteMap allows the caller to receive updates when the map or map // ListenOnRemoteMap allows the caller to receive updates when the map or map
...@@ -456,17 +451,12 @@ func (r *RemoteKV) ListenOnRemoteMap(_ js.Value, args []js.Value) any { ...@@ -456,17 +451,12 @@ func (r *RemoteKV) ListenOnRemoteMap(_ js.Value, args []js.Value) any {
localEvents = args[3].Bool() localEvents = args[3].Bool()
} }
promiseFn := func(resolve, reject func(args ...any) js.Value) {
id, err := r.api.ListenOnRemoteMap(mapName, version, cb, id, err := r.api.ListenOnRemoteMap(mapName, version, cb,
localEvents) localEvents)
if err != nil { if err != nil {
reject(exception.NewTrace(err)) exception.ThrowTrace(err)
} else {
resolve(id)
} }
} return id
return utils.CreatePromise(promiseFn)
} }
// GetAllRemoteKeyListeners returns a JSON list of { key: [id, id, id, ...] }, // GetAllRemoteKeyListeners returns a JSON list of { key: [id, id, id, ...] },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment