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
b4f099f9
Commit
b4f099f9
authored
2 years ago
by
Jono Wenger
Browse files
Options
Downloads
Patches
Plain Diff
Wrap calls that start indexedDb with a promise to make them async
parent
99168c7c
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!60
Revert "Fail a test to be sure it works"
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
wasm/channels.go
+34
-30
34 additions, 30 deletions
wasm/channels.go
with
34 additions
and
30 deletions
wasm/channels.go
+
34
−
30
View file @
b4f099f9
...
@@ -92,25 +92,27 @@ func NewChannelsManager(_ js.Value, args []js.Value) interface{} {
...
@@ -92,25 +92,27 @@ func NewChannelsManager(_ js.Value, args []js.Value) interface{} {
// retrieved using [UserDiscovery.GetID].
// retrieved using [UserDiscovery.GetID].
// - args[2] - username (string).
// - args[2] - username (string).
//
//
// Returns:
// Returns
a promise
:
// - Javascript representation of the [bindings.ChannelsManager]
object.
// -
Resolves to a
Javascript representation of the [bindings.ChannelsManager]
//
- Throws a TypeError if initialising indexedDb or created the new channel
//
object.
//
manager fails.
//
- Rejected with an error if loading indexedDb or the
manager fails.
func
NewChannelsManagerWithIndexedDb
(
_
js
.
Value
,
args
[]
js
.
Value
)
interface
{}
{
func
NewChannelsManagerWithIndexedDb
(
_
js
.
Value
,
args
[]
js
.
Value
)
interface
{}
{
promiseFn
:=
func
(
resolve
,
reject
func
(
args
...
interface
{})
js
.
Value
)
{
em
,
err
:=
indexedDb
.
NewWasmEventModel
(
args
[
2
]
.
String
())
em
,
err
:=
indexedDb
.
NewWasmEventModel
(
args
[
2
]
.
String
())
if
err
!=
nil
{
if
err
!=
nil
{
utils
.
Throw
(
utils
.
TypeError
,
err
)
reject
(
utils
.
JsTrace
(
err
))
return
nil
}
}
cm
,
err
:=
bindings
.
NewChannelsManagerGoEventModel
(
cm
,
err
:=
bindings
.
NewChannelsManagerGoEventModel
(
args
[
0
]
.
Int
(),
args
[
1
]
.
Int
(),
em
)
args
[
0
]
.
Int
(),
args
[
1
]
.
Int
(),
em
)
if
err
!=
nil
{
if
err
!=
nil
{
utils
.
Throw
(
utils
.
TypeError
,
err
)
reject
(
utils
.
JsTrace
(
err
))
return
nil
}
else
{
resolve
(
newChannelsManagerJS
(
cm
))
}
}
}
return
newChannelsManagerJS
(
cm
)
return
utils
.
CreatePromise
(
promiseFn
)
}
}
// NewChannelsManagerWithIndexedDbDummyNameService constructs a
// NewChannelsManagerWithIndexedDbDummyNameService constructs a
...
@@ -124,25 +126,27 @@ func NewChannelsManagerWithIndexedDb(_ js.Value, args []js.Value) interface{} {
...
@@ -124,25 +126,27 @@ func NewChannelsManagerWithIndexedDb(_ js.Value, args []js.Value) interface{} {
// using [Cmix.GetID].
// using [Cmix.GetID].
// - args[1] - Username (string).
// - args[1] - Username (string).
//
//
// Returns:
// Returns
a promise
:
// - Javascript representation of the [bindings.ChannelsManager]
object.
// -
Resolves to a
Javascript representation of the [bindings.ChannelsManager]
//
- Throws a TypeError if initialising indexedDb or created the new channel
//
object.
//
manager fails.
//
- Rejected with an error if loading indexedDb or the
manager fails.
func
NewChannelsManagerWithIndexedDbDummyNameService
(
_
js
.
Value
,
args
[]
js
.
Value
)
interface
{}
{
func
NewChannelsManagerWithIndexedDbDummyNameService
(
_
js
.
Value
,
args
[]
js
.
Value
)
interface
{}
{
promiseFn
:=
func
(
resolve
,
reject
func
(
args
...
interface
{})
js
.
Value
)
{
em
,
err
:=
indexedDb
.
NewWasmEventModel
(
args
[
1
]
.
String
())
em
,
err
:=
indexedDb
.
NewWasmEventModel
(
args
[
1
]
.
String
())
if
err
!=
nil
{
if
err
!=
nil
{
utils
.
Throw
(
utils
.
TypeError
,
err
)
reject
(
utils
.
JsTrace
(
err
))
return
nil
}
}
cm
,
err
:=
bindings
.
NewChannelsManagerGoEventModelDummyNameService
(
cm
,
err
:=
bindings
.
NewChannelsManagerGoEventModelDummyNameService
(
args
[
0
]
.
Int
(),
args
[
1
]
.
String
(),
em
)
args
[
0
]
.
Int
(),
args
[
1
]
.
String
(),
em
)
if
err
!=
nil
{
if
err
!=
nil
{
utils
.
Throw
(
utils
.
TypeError
,
err
)
reject
(
utils
.
JsTrace
(
err
))
return
nil
}
else
{
resolve
(
newChannelsManagerJS
(
cm
))
}
}
}
return
newChannelsManagerJS
(
cm
)
return
utils
.
CreatePromise
(
promiseFn
)
}
}
// NewChannelsManagerDummyNameService constructs a [ChannelsManager]
// NewChannelsManagerDummyNameService constructs a [ChannelsManager]
...
...
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