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
411148a6
Commit
411148a6
authored
May 25, 2023
by
Alejandro Celaya
Committed by
Alejandro Celaya
May 25, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate watch module to TS
parent
9f84b43f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
12 deletions
+15
-12
time.ts
src/sidebar/util/time.ts
+1
-0
watch.ts
src/sidebar/util/watch.ts
+14
-12
No files found.
src/sidebar/util/time.ts
View file @
411148a6
...
@@ -35,6 +35,7 @@ type IntlType = typeof window.Intl;
...
@@ -35,6 +35,7 @@ type IntlType = typeof window.Intl;
function
format
(
function
format
(
date
:
Date
,
date
:
Date
,
options
:
Intl
.
DateTimeFormatOptions
,
options
:
Intl
.
DateTimeFormatOptions
,
/* istanbul ignore next */
Intl
:
IntlType
=
window
.
Intl
Intl
:
IntlType
=
window
.
Intl
):
string
{
):
string
{
const
key
=
JSON
.
stringify
(
options
);
const
key
=
JSON
.
stringify
(
options
);
...
...
src/sidebar/util/watch.
j
s
→
src/sidebar/util/watch.
t
s
View file @
411148a6
...
@@ -32,19 +32,21 @@
...
@@ -32,19 +32,21 @@
* );
* );
*
*
* @template T
* @template T
* @param {(callback: () => void) => VoidFunction} subscribe - Function to
* @param subscribe - Function to subscribe to changes from the data source.
* subscribe to changes from the data source.
* @param getValue - Callback that extracts information of interest from the
* @param {() => T} getValue - Callback that extracts information of interest
* data source.
* from the data source.
* @param callback - A callback that receives the data extracted by `getValue`.
* @param {(current: T, previous: T) => void} callback -
* It is called each time the result of `getValue` changes.
* A callback that receives the data extracted by `getValue`. It is called
* @param compare - Comparison function that tests whether the results of two
* each time the result of `getValue` changes.
* `getValue` calls are equal. If omitted, a strict equality check is used
* @param {((current: T, previous: T) => boolean)} [compare] -
* @return Return value of `subscribe`
* Comparison function that tests whether the results of two `getValue` calls
* are equal. If omitted, a strict equality check is used
* @return {VoidFunction} - Return value of `subscribe`
*/
*/
export
function
watch
(
subscribe
,
getValue
,
callback
,
compare
)
{
export
function
watch
<
T
>
(
subscribe
:
(
callback
:
VoidFunction
)
=>
VoidFunction
,
getValue
:
()
=>
T
,
callback
:
(
current
:
T
,
previous
:
T
)
=>
void
,
compare
?:
(
current
:
T
,
previous
:
T
)
=>
boolean
):
VoidFunction
{
let
prevValue
=
getValue
();
let
prevValue
=
getValue
();
const
unsubscribe
=
subscribe
(()
=>
{
const
unsubscribe
=
subscribe
(()
=>
{
const
currentValue
=
getValue
();
const
currentValue
=
getValue
();
...
...
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