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

make local events flag optional

parent dcad173f
No related branches found
No related tags found
2 merge requests!126Updates for client HavenBeta,!109Project/haven beta
...@@ -385,6 +385,7 @@ func (r *RemoteKV) GetMapElement(_ js.Value, args []js.Value) any { ...@@ -385,6 +385,7 @@ func (r *RemoteKV) GetMapElement(_ js.Value, args []js.Value) any {
// - args[0] - the key string // - args[0] - the key string
// - args[1] - the version int // - args[1] - the version int
// - args[2] - the [KeyChangedByRemoteCallback] javascript callback // - args[2] - the [KeyChangedByRemoteCallback] javascript callback
// - args[3] - set the localEvents flag to true or false (optional)
// //
// Returns a promise with an error if any or the json of the existing // Returns a promise with an error if any or the json of the existing
// [versioned.Object], e.g.: // [versioned.Object], e.g.:
...@@ -396,8 +397,13 @@ func (r *RemoteKV) ListenOnRemoteKey(_ js.Value, args []js.Value) any { ...@@ -396,8 +397,13 @@ func (r *RemoteKV) ListenOnRemoteKey(_ js.Value, args []js.Value) any {
version := int64(args[1].Int()) version := int64(args[1].Int())
cb := newKeyChangedByRemoteCallback(args[2]) cb := newKeyChangedByRemoteCallback(args[2])
localEvents := true
if !args[3].IsUndefined() {
localEvents = args[3].Bool()
}
promiseFn := func(resolve, reject func(args ...any) js.Value) { promiseFn := func(resolve, reject func(args ...any) js.Value) {
err := r.api.ListenOnRemoteKey(key, version, cb, true) err := r.api.ListenOnRemoteKey(key, version, cb, localEvents)
if err != nil { if err != nil {
reject(exception.NewTrace(err)) reject(exception.NewTrace(err))
} else { } else {
...@@ -415,6 +421,7 @@ func (r *RemoteKV) ListenOnRemoteKey(_ js.Value, args []js.Value) any { ...@@ -415,6 +421,7 @@ func (r *RemoteKV) ListenOnRemoteKey(_ js.Value, args []js.Value) any {
// - args[0] - the mapName string // - args[0] - the mapName string
// - args[1] - the version int // - args[1] - the version int
// - args[2] - the [MapChangedByRemoteCallback] javascript callback // - args[2] - the [MapChangedByRemoteCallback] javascript callback
// - args[3] - set the localEvents flag to true or false (optional)
// //
// Returns a promise with an error if any or the json of the existing // Returns a promise with an error if any or the json of the existing
// the [map[string]versioned.Object] JSON value, e.g.: // the [map[string]versioned.Object] JSON value, e.g.:
...@@ -426,8 +433,13 @@ func (r *RemoteKV) ListenOnRemoteMap(_ js.Value, args []js.Value) any { ...@@ -426,8 +433,13 @@ func (r *RemoteKV) ListenOnRemoteMap(_ js.Value, args []js.Value) any {
version := int64(args[1].Int()) version := int64(args[1].Int())
cb := newMapChangedByRemoteCallback(args[2]) cb := newMapChangedByRemoteCallback(args[2])
localEvents := true
if !args[3].IsUndefined() {
localEvents = args[3].Bool()
}
promiseFn := func(resolve, reject func(args ...any) js.Value) { promiseFn := func(resolve, reject func(args ...any) js.Value) {
err := r.api.ListenOnRemoteMap(mapName, version, cb, true) err := r.api.ListenOnRemoteMap(mapName, version, cb, localEvents)
if err != nil { if err != nil {
reject(exception.NewTrace(err)) reject(exception.NewTrace(err))
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment