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
Show 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> {
...
@@ -7,6 +7,9 @@ export declare class Timer extends EventEmitter<any> {
_timer
:
number
|
undefined
;
_timer
:
number
|
undefined
;
constructor
(
repeatCount
:
number
,
delay
?:
number
);
constructor
(
repeatCount
:
number
,
delay
?:
number
);
start
():
void
;
start
():
void
;
_isPause
:
boolean
;
pause
():
void
;
resume
():
void
;
stop
():
void
;
stop
():
void
;
reset
():
void
;
reset
():
void
;
}
}
dist/time/Timer.js
View file @
730b49c2
...
@@ -21,6 +21,7 @@ var Timer = /** @class */ (function (_super) {
...
@@ -21,6 +21,7 @@ var Timer = /** @class */ (function (_super) {
if
(
delay
===
void
0
)
{
delay
=
1000
;
}
if
(
delay
===
void
0
)
{
delay
=
1000
;
}
var
_this
=
_super
.
call
(
this
)
||
this
;
var
_this
=
_super
.
call
(
this
)
||
this
;
_this
.
_running
=
false
;
_this
.
_running
=
false
;
_this
.
_isPause
=
false
;
_this
.
repeatCount
=
repeatCount
;
_this
.
repeatCount
=
repeatCount
;
_this
.
delay
=
delay
;
_this
.
delay
=
delay
;
_this
.
currentCount
=
0
;
_this
.
currentCount
=
0
;
...
@@ -30,6 +31,8 @@ var Timer = /** @class */ (function (_super) {
...
@@ -30,6 +31,8 @@ var Timer = /** @class */ (function (_super) {
var
_this
=
this
;
var
_this
=
this
;
this
.
_running
=
true
;
this
.
_running
=
true
;
this
.
_timer
=
setInterval
(
function
()
{
this
.
_timer
=
setInterval
(
function
()
{
if
(
_this
.
_isPause
)
return
;
_this
.
currentCount
++
;
_this
.
currentCount
++
;
_this
.
emit
(
"timer"
);
_this
.
emit
(
"timer"
);
if
(
_this
.
currentCount
==
_this
.
repeatCount
)
{
if
(
_this
.
currentCount
==
_this
.
repeatCount
)
{
...
@@ -38,6 +41,12 @@ var Timer = /** @class */ (function (_super) {
...
@@ -38,6 +41,12 @@ var Timer = /** @class */ (function (_super) {
}
}
},
this
.
delay
);
},
this
.
delay
);
};
};
Timer
.
prototype
.
pause
=
function
()
{
this
.
_isPause
=
true
;
};
Timer
.
prototype
.
resume
=
function
()
{
this
.
_isPause
=
false
;
};
Timer
.
prototype
.
stop
=
function
()
{
Timer
.
prototype
.
stop
=
function
()
{
this
.
_running
=
false
;
this
.
_running
=
false
;
clearInterval
(
this
.
_timer
);
clearInterval
(
this
.
_timer
);
...
...
src/time/Timer.ts
View file @
730b49c2
...
@@ -16,6 +16,7 @@ export class Timer extends EventEmitter<any> {
...
@@ -16,6 +16,7 @@ export class Timer extends EventEmitter<any> {
start
()
{
start
()
{
this
.
_running
=
true
;
this
.
_running
=
true
;
this
.
_timer
=
setInterval
(()
=>
{
this
.
_timer
=
setInterval
(()
=>
{
if
(
this
.
_isPause
)
return
;
this
.
currentCount
++
;
this
.
currentCount
++
;
this
.
emit
(
"timer"
);
this
.
emit
(
"timer"
);
if
(
this
.
currentCount
==
this
.
repeatCount
)
{
if
(
this
.
currentCount
==
this
.
repeatCount
)
{
...
@@ -25,6 +26,15 @@ export class Timer extends EventEmitter<any> {
...
@@ -25,6 +26,15 @@ export class Timer extends EventEmitter<any> {
},
this
.
delay
);
},
this
.
delay
);
}
}
_isPause
=
false
;
pause
()
{
this
.
_isPause
=
true
}
resume
()
{
this
.
_isPause
=
false
}
stop
()
{
stop
()
{
this
.
_running
=
false
;
this
.
_running
=
false
;
clearInterval
(
this
.
_timer
);
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