Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
siibra-explorer
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Xiao Gui
siibra-explorer
Commits
262ad37d
Commit
262ad37d
authored
3 years ago
by
Xiao Gui
Browse files
Options
Downloads
Patches
Plain Diff
bugfix: pli desc
bugfix: race promise
parent
7dc89e6b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
common/util.js
+1
-1
1 addition, 1 deletion
common/util.js
common/util.spec.js
+53
-1
53 additions, 1 deletion
common/util.spec.js
src/viewerModule/viewerCmp/viewerCmp.component.ts
+9
-11
9 additions, 11 deletions
src/viewerModule/viewerCmp/viewerCmp.component.ts
with
63 additions
and
13 deletions
common/util.js
+
1
−
1
View file @
262ad37d
...
...
@@ -142,7 +142,7 @@
throw
new
Error
(
`fn failed
${
retries
}
times. Aborting.`
)
}
exports
.
race
=
async
(
fn
,
{
timeout
=
defaultConfig
.
timeout
})
=>
{
exports
.
race
=
async
(
fn
,
{
timeout
=
defaultConfig
.
timeout
}
=
{}
)
=>
{
return
Promise
.
race
([
fn
(),
new
Promise
((
_rs
,
rj
)
=>
setTimeout
(
rj
,
timeout
,
`timed out:
${
timeout
}
`
))
...
...
This diff is collapsed.
Click to expand it.
common/util.spec.js
+
53
−
1
View file @
262ad37d
import
{
getIdFromFullId
,
strToRgb
,
verifyPositionArg
,
arrayOrderedEql
}
from
'
./util
'
import
{
race
,
getIdFromFullId
,
strToRgb
,
verifyPositionArg
,
arrayOrderedEql
}
from
'
./util
'
describe
(
'
common/util.js
'
,
()
=>
{
describe
(
'
getIdFromFullId
'
,
()
=>
{
...
...
@@ -150,4 +150,56 @@ describe('common/util.js', () => {
})
})
})
describe
(
"
> race
"
,
()
=>
{
const
defaultTimeout
=
1000
describe
(
"
> without argument
"
,
()
=>
{
it
(
'
> resolve should work
'
,
async
()
=>
{
await
race
(
async
()
=>
{
await
new
Promise
(
rs
=>
setTimeout
(
rs
,
160
,
'
hello
'
))
})
expect
(
true
).
toEqual
(
true
)
}),
it
(
'
> reject should work
'
,
async
()
=>
{
const
start
=
performance
.
now
()
try
{
await
race
(
async
()
=>
{
await
new
Promise
(
rs
=>
setTimeout
(
rs
,
5000
,
'
hello
'
))
})
expect
(
true
).
toEqual
(
false
)
}
catch
(
e
)
{
}
finally
{
const
end
=
performance
.
now
()
expect
(
end
-
start
).
toBeGreaterThan
(
defaultTimeout
)
expect
(
end
-
start
).
toBeLessThan
(
defaultTimeout
+
10
)
}
})
})
describe
(
"
> with argument
"
,
()
=>
{
const
timeout
=
500
it
(
'
> resolve should work
'
,
async
()
=>
{
await
race
(
async
()
=>
{
await
new
Promise
(
rs
=>
setTimeout
(
rs
,
160
,
'
hello
'
))
},
{
timeout
})
expect
(
true
).
toEqual
(
true
)
}),
it
(
'
> reject should work
'
,
async
()
=>
{
const
start
=
performance
.
now
()
try
{
await
race
(
async
()
=>
{
await
new
Promise
(
rs
=>
setTimeout
(
rs
,
1000
,
'
hello
'
))
},
{
timeout
}
)
expect
(
true
).
toEqual
(
false
)
}
catch
(
e
)
{
}
finally
{
const
end
=
performance
.
now
()
expect
(
end
-
start
).
toBeGreaterThan
(
timeout
)
expect
(
end
-
start
).
toBeLessThan
(
timeout
+
10
)
}
})
})
})
})
This diff is collapsed.
Click to expand it.
src/viewerModule/viewerCmp/viewerCmp.component.ts
+
9
−
11
View file @
262ad37d
import
{
ChangeDetectionStrategy
,
ChangeDetectorRef
,
Component
,
ComponentFactory
,
ComponentFactoryResolver
,
Inject
,
Injector
,
Input
,
OnDestroy
,
Optional
,
TemplateRef
,
ViewChild
,
ViewContainerRef
}
from
"
@angular/core
"
;
import
{
select
,
Store
}
from
"
@ngrx/store
"
;
import
{
combineLatest
,
merge
,
NEVER
,
Observable
,
of
,
Subscription
}
from
"
rxjs
"
;
import
{
catchError
,
debounceTime
,
distinctUntilChanged
,
map
,
shareReplay
,
startWith
,
switchMap
,
mapTo
}
from
"
rxjs/operators
"
;
import
{
catchError
,
debounceTime
,
distinctUntilChanged
,
map
,
shareReplay
,
startWith
,
switchMap
,
mapTo
,
filter
}
from
"
rxjs/operators
"
;
import
{
viewerStateSetSelectedRegions
}
from
"
src/services/state/viewerState/actions
"
;
import
{
viewerStateContextedSelectedRegionsSelector
,
...
...
@@ -207,16 +207,14 @@ export class ViewerCmp implements OnDestroy {
})
)
||
NEVER
,
this
.
_1umVoi$
.
pipe
(
map
(
flag
=>
flag
?
({
title
:
this
.
_1umTitle
,
description
:
this
.
_1umDesc
,
url
:
this
.
_1umLink
?
[{
doi
:
this
.
_1umLink
}]
:
[]
})
:
null
)
filter
(
flag
=>
flag
),
map
(()
=>
({
title
:
this
.
_1umTitle
,
description
:
this
.
_1umDesc
,
url
:
this
.
_1umLink
?
[{
doi
:
this
.
_1umLink
}]
:
[]
}))
)
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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