Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
teddi
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
wildfirecode13
teddi
Commits
730b49c2
Commit
730b49c2
authored
Nov 28, 2020
by
wildfirecode13
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
4363286a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
0 deletions
+22
-0
Timer.d.ts
dist/time/Timer.d.ts
+3
-0
Timer.js
dist/time/Timer.js
+9
-0
Timer.ts
src/time/Timer.ts
+10
-0
No files found.
dist/time/Timer.d.ts
View file @
730b49c2
...
...
@@ -7,6 +7,9 @@ export declare class Timer extends EventEmitter<any> {
_timer
:
number
|
undefined
;
constructor
(
repeatCount
:
number
,
delay
?:
number
);
start
():
void
;
_isPause
:
boolean
;
pause
():
void
;
resume
():
void
;
stop
():
void
;
reset
():
void
;
}
dist/time/Timer.js
View file @
730b49c2
...
...
@@ -21,6 +21,7 @@ var Timer = /** @class */ (function (_super) {
if
(
delay
===
void
0
)
{
delay
=
1000
;
}
var
_this
=
_super
.
call
(
this
)
||
this
;
_this
.
_running
=
false
;
_this
.
_isPause
=
false
;
_this
.
repeatCount
=
repeatCount
;
_this
.
delay
=
delay
;
_this
.
currentCount
=
0
;
...
...
@@ -30,6 +31,8 @@ var Timer = /** @class */ (function (_super) {
var
_this
=
this
;
this
.
_running
=
true
;
this
.
_timer
=
setInterval
(
function
()
{
if
(
_this
.
_isPause
)
return
;
_this
.
currentCount
++
;
_this
.
emit
(
"timer"
);
if
(
_this
.
currentCount
==
_this
.
repeatCount
)
{
...
...
@@ -38,6 +41,12 @@ var Timer = /** @class */ (function (_super) {
}
},
this
.
delay
);
};
Timer
.
prototype
.
pause
=
function
()
{
this
.
_isPause
=
true
;
};
Timer
.
prototype
.
resume
=
function
()
{
this
.
_isPause
=
false
;
};
Timer
.
prototype
.
stop
=
function
()
{
this
.
_running
=
false
;
clearInterval
(
this
.
_timer
);
...
...
src/time/Timer.ts
View file @
730b49c2
...
...
@@ -16,6 +16,7 @@ export class Timer extends EventEmitter<any> {
start
()
{
this
.
_running
=
true
;
this
.
_timer
=
setInterval
(()
=>
{
if
(
this
.
_isPause
)
return
;
this
.
currentCount
++
;
this
.
emit
(
"timer"
);
if
(
this
.
currentCount
==
this
.
repeatCount
)
{
...
...
@@ -25,6 +26,15 @@ export class Timer extends EventEmitter<any> {
},
this
.
delay
);
}
_isPause
=
false
;
pause
()
{
this
.
_isPause
=
true
}
resume
()
{
this
.
_isPause
=
false
}
stop
()
{
this
.
_running
=
false
;
clearInterval
(
this
.
_timer
);
...
...
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