diff --git a/go.mod b/go.mod index 746132d7a08a89a7eac8f2e4b18ba5e6a57d0315..c1b42253aea485818e7ed1095c983c8d83210b24 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/spf13/cobra v1.7.0 github.com/spf13/jwalterweatherman v1.1.0 github.com/stretchr/testify v1.8.2 - gitlab.com/elixxir/client/v4 v4.6.4-0.20230531195851-a65797612a21 + gitlab.com/elixxir/client/v4 v4.6.4-0.20230531212217-e21b55fbf23c gitlab.com/elixxir/crypto v0.0.7-0.20230522162218-45433d877235 gitlab.com/elixxir/primitives v0.0.3-0.20230214180039-9a25e2d3969c gitlab.com/elixxir/wasm-utils v0.0.0-20230522231408-a43b2c1481b2 diff --git a/go.sum b/go.sum index 5a8bfe66679870d7dd939658df85c4538eee27c8..bfb69092f1207c254276234cb5f68725ccef6312 100644 --- a/go.sum +++ b/go.sum @@ -539,6 +539,8 @@ gitlab.com/elixxir/client/v4 v4.6.4-0.20230531195028-ad25aee27c19 h1:OLZTJAqRm1h gitlab.com/elixxir/client/v4 v4.6.4-0.20230531195028-ad25aee27c19/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8= gitlab.com/elixxir/client/v4 v4.6.4-0.20230531195851-a65797612a21 h1:u4H7ITaOwO4aQoSJCo8zpfRpenaqgHuvjqF3GAe8RrE= gitlab.com/elixxir/client/v4 v4.6.4-0.20230531195851-a65797612a21/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8= +gitlab.com/elixxir/client/v4 v4.6.4-0.20230531212217-e21b55fbf23c h1:6OTyW9U/ntZ41Xry+8qDkOH4LoxhlyWTwKpAxi2fvZY= +gitlab.com/elixxir/client/v4 v4.6.4-0.20230531212217-e21b55fbf23c/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8= gitlab.com/elixxir/comms v0.0.4-0.20230519211512-4a998f4b0938 h1:f27+QUFiGWrprKm+fstOg3ABkYLpWcZi3+8Lf5eDnqY= gitlab.com/elixxir/comms v0.0.4-0.20230519211512-4a998f4b0938/go.mod h1:z+qW0D9VpY5QKTd7wRlb5SK4kBNqLYsa4DXBcUXue9Q= gitlab.com/elixxir/crypto v0.0.7-0.20230522162218-45433d877235 h1:0BySdXTzRWxzH8k5RiNNMmmn2lpuQWLVcDDA/7ehyqc= diff --git a/wasm/collective.go b/wasm/collective.go index c2b0b3feaf199201d8505ce70d35099515305e60..cd3dcc38247137910c3921f7d0d4ee624168c827 100644 --- a/wasm/collective.go +++ b/wasm/collective.go @@ -385,6 +385,7 @@ func (r *RemoteKV) GetMapElement(_ js.Value, args []js.Value) any { // - args[0] - the key string // - args[1] - the version int // - 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 // [versioned.Object], e.g.: @@ -396,12 +397,17 @@ func (r *RemoteKV) ListenOnRemoteKey(_ js.Value, args []js.Value) any { version := int64(args[1].Int()) cb := newKeyChangedByRemoteCallback(args[2]) + localEvents := true + if !args[3].IsUndefined() { + localEvents = args[3].Bool() + } + promiseFn := func(resolve, reject func(args ...any) js.Value) { - deleted, err := r.api.ListenOnRemoteKey(key, version, cb) + err := r.api.ListenOnRemoteKey(key, version, cb, localEvents) if err != nil { reject(exception.NewTrace(err)) } else { - resolve(utils.CopyBytesToJS(deleted)) + resolve() } } @@ -415,6 +421,7 @@ func (r *RemoteKV) ListenOnRemoteKey(_ js.Value, args []js.Value) any { // - args[0] - the mapName string // - args[1] - the version int // - 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 // the [map[string]versioned.Object] JSON value, e.g.: @@ -426,12 +433,17 @@ func (r *RemoteKV) ListenOnRemoteMap(_ js.Value, args []js.Value) any { version := int64(args[1].Int()) cb := newMapChangedByRemoteCallback(args[2]) + localEvents := true + if !args[3].IsUndefined() { + localEvents = args[3].Bool() + } + promiseFn := func(resolve, reject func(args ...any) js.Value) { - deleted, err := r.api.ListenOnRemoteMap(mapName, version, cb) + err := r.api.ListenOnRemoteMap(mapName, version, cb, localEvents) if err != nil { reject(exception.NewTrace(err)) } else { - resolve(utils.CopyBytesToJS(deleted)) + resolve() } }