Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
13aae23d
Commit
13aae23d
authored
Jun 15, 2023
by
Alejandro Celaya
Committed by
Alejandro Celaya
Jun 15, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate util module to TS
parent
8a409406
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
13 deletions
+13
-13
util.ts
src/sidebar/store/util.ts
+13
-13
No files found.
src/sidebar/store/util.
j
s
→
src/sidebar/store/util.
t
s
View file @
13aae23d
/** @typedef {import('redux').Store} Store */
import
type
{
Store
}
from
'redux'
;
/**
/**
* Return an object where each key in `updateFns` is mapped to the key itself.
* Return an object where each key in `updateFns` is mapped to the key itself.
*
*
* @template {Record<string,Function>} T
* @param reducers - Object containing reducer functions
* @param {T} reducers - Object containing reducer functions
* @return {{ [index in keyof T]: string }}
*/
*/
export
function
actionTypes
(
reducers
)
{
export
function
actionTypes
<
T
extends
Record
<
string
,
unknown
>>
(
return
Object
.
keys
(
reducers
).
reduce
((
types
,
key
)
=>
{
reducers
:
T
):
{
[
index
in
keyof
T
]:
string
}
{
return
Object
.
keys
(
reducers
).
reduce
<
any
>
((
types
,
key
)
=>
{
types
[
key
]
=
key
;
types
[
key
]
=
key
;
return
types
;
return
types
;
},
/** @type {any} */
({})
);
},
{}
);
}
}
/**
/**
...
@@ -20,13 +20,13 @@ export function actionTypes(reducers) {
...
@@ -20,13 +20,13 @@ export function actionTypes(reducers) {
* `await` returns a Promise which resolves when a selector function,
* `await` returns a Promise which resolves when a selector function,
* which reads values from a Redux store, returns non-null.
* which reads values from a Redux store, returns non-null.
*
*
* @template T
* @param selector - Function which returns a value from the store if the
* @param {import('redux').Store} store
* criteria is met or `null` otherwise.
* @param {(s: Store) => T|null} selector - Function which returns a value from the
* store if the criteria is met or `null` otherwise.
* @return {Promise<T>}
*/
*/
export
function
awaitStateChange
(
store
,
selector
)
{
export
function
awaitStateChange
<
T
>
(
store
:
Store
,
selector
:
(
s
:
Store
)
=>
T
|
null
):
Promise
<
T
>
{
const
result
=
selector
(
store
);
const
result
=
selector
(
store
);
if
(
result
!==
null
)
{
if
(
result
!==
null
)
{
return
Promise
.
resolve
(
result
);
return
Promise
.
resolve
(
result
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment