Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
xxdk-wasm
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
xxdk-wasm
Commits
69b0cc3f
Commit
69b0cc3f
authored
1 year ago
by
Richard T. Carback III
Browse files
Options
Downloads
Patches
Plain Diff
Add a guard, don't allow loads when New is running
parent
34ab9a77
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!109
Project/haven beta
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
wasm/cmix.go
+10
-0
10 additions, 0 deletions
wasm/cmix.go
with
10 additions
and
0 deletions
wasm/cmix.go
+
10
−
0
View file @
69b0cc3f
...
...
@@ -10,6 +10,8 @@
package
wasm
import
(
"fmt"
"sync/atomic"
"syscall/js"
"gitlab.com/elixxir/client/v4/bindings"
...
...
@@ -17,6 +19,8 @@ import (
"gitlab.com/elixxir/wasm-utils/utils"
)
var
initializing
atomic
.
Bool
// Cmix wraps the [bindings.Cmix] object so its methods can be wrapped to be
// Javascript compatible.
type
Cmix
struct
{
...
...
@@ -124,6 +128,7 @@ func NewCmix(_ js.Value, args []js.Value) any {
// - Resolves on success.
// - Rejected with an error if creating a new cMix client fails.
func
NewSynchronizedCmix
(
_
js
.
Value
,
args
[]
js
.
Value
)
any
{
initializing
.
Store
(
true
)
ndfJSON
:=
args
[
0
]
.
String
()
storageDir
:=
args
[
1
]
.
String
()
password
:=
utils
.
CopyBytesToGo
(
args
[
2
])
...
...
@@ -135,6 +140,7 @@ func NewSynchronizedCmix(_ js.Value, args []js.Value) any {
if
err
!=
nil
{
reject
(
exception
.
NewTrace
(
err
))
}
else
{
initializing
.
Store
(
false
)
resolve
()
}
}
...
...
@@ -196,6 +202,10 @@ func LoadSynchronizedCmix(_ js.Value, args []js.Value) any {
cmixParamsJSON
:=
utils
.
CopyBytesToGo
(
args
[
3
])
promiseFn
:=
func
(
resolve
,
reject
func
(
args
...
any
)
js
.
Value
)
{
if
initializing
.
Load
()
{
reject
(
exception
.
NewTrace
(
fmt
.
Errorf
(
"cannot Load when New is running"
)))
}
net
,
err
:=
bindings
.
LoadSynchronizedCmix
(
storageDir
,
password
,
rs
,
cmixParamsJSON
)
if
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment