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
a68759ce
Commit
a68759ce
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 sidebar/store index module to TS
parent
13aae23d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
index.ts
src/sidebar/store/index.ts
+6
-6
No files found.
src/sidebar/store/index.
j
s
→
src/sidebar/store/index.
t
s
View file @
a68759ce
import
type
{
SidebarSettings
}
from
'../../types/config'
;
import
{
useService
}
from
'../service-context'
;
import
{
useService
}
from
'../service-context'
;
import
{
createStore
}
from
'./create-store'
;
import
{
createStore
}
from
'./create-store'
;
import
{
debugMiddleware
}
from
'./debug-middleware'
;
import
{
debugMiddleware
}
from
'./debug-middleware'
;
...
@@ -19,7 +20,7 @@ import { toastMessagesModule } from './modules/toast-messages';
...
@@ -19,7 +20,7 @@ import { toastMessagesModule } from './modules/toast-messages';
import
{
viewerModule
}
from
'./modules/viewer'
;
import
{
viewerModule
}
from
'./modules/viewer'
;
import
{
useStore
}
from
'./use-store'
;
import
{
useStore
}
from
'./use-store'
;
/** @typedef {ReturnType<createSidebarStore>} SidebarStore */
export
type
SidebarStore
=
ReturnType
<
typeof
createSidebarStore
>
;
/**
/**
* Create the central state store for the sidebar application.
* Create the central state store for the sidebar application.
...
@@ -30,15 +31,14 @@ import { useStore } from './use-store';
...
@@ -30,15 +31,14 @@ import { useStore } from './use-store';
*
*
* [1] https://redux.js.org
* [1] https://redux.js.org
*
*
* @param {import('../../types/config').SidebarSettings} settings
* @inject
* @inject
*/
*/
export
function
createSidebarStore
(
settings
)
{
export
function
createSidebarStore
(
settings
:
SidebarSettings
)
{
const
middleware
=
[
debugMiddleware
];
const
middleware
=
[
debugMiddleware
];
// `const` type gives `modules` a tuple type, which allows `createStore`
// `const` type gives `modules` a tuple type, which allows `createStore`
// to infer properties (eg. action and selector methods) of returned store.
// to infer properties (eg. action and selector methods) of returned store.
const
modules
=
/** @type {const} */
(
[
const
modules
=
[
activityModule
,
activityModule
,
annotationsModule
,
annotationsModule
,
defaultsModule
,
defaultsModule
,
...
@@ -55,7 +55,7 @@ export function createSidebarStore(settings) {
...
@@ -55,7 +55,7 @@ export function createSidebarStore(settings) {
sidebarPanelsModule
,
sidebarPanelsModule
,
toastMessagesModule
,
toastMessagesModule
,
viewerModule
,
viewerModule
,
]
)
;
]
as
const
;
return
createStore
(
modules
,
[
settings
],
middleware
);
return
createStore
(
modules
,
[
settings
],
middleware
);
}
}
...
@@ -67,6 +67,6 @@ export function createSidebarStore(settings) {
...
@@ -67,6 +67,6 @@ export function createSidebarStore(settings) {
* {@link useStore}.
* {@link useStore}.
*/
*/
export
function
useSidebarStore
()
{
export
function
useSidebarStore
()
{
const
store
=
/** @type {SidebarStore} */
(
useService
(
'store'
))
;
const
store
=
useService
(
'store'
)
as
SidebarStore
;
return
useStore
(
store
);
return
useStore
(
store
);
}
}
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