main
Last change
on this file since 0c6b92a was 0c6b92a, checked in by stefan toskovski <stefantoska84@…>, 5 weeks ago |
Pred finalna verzija
|
-
Property mode
set to
100644
|
File size:
556 bytes
|
Line | |
---|
1 | let canSave = true;
|
---|
2 | const mapSaveEvent = new CustomEvent("mapsave",{});
|
---|
3 | const setCanSave = (value) => {
|
---|
4 | canSave = value;
|
---|
5 | }
|
---|
6 | /**
|
---|
7 | * Triggers a save event for the floor you are currently on with a debounce time of 3s;
|
---|
8 | * @example triggerMapSave() - will save the floor once, and after 3s again.
|
---|
9 | */
|
---|
10 | const triggerMapSave = () => {
|
---|
11 | if(!canSave) return;
|
---|
12 |
|
---|
13 | window.dispatchEvent(mapSaveEvent)
|
---|
14 | setCanSave(false);
|
---|
15 | setTimeout(() => {
|
---|
16 | setCanSave(true);
|
---|
17 | window.dispatchEvent(mapSaveEvent)
|
---|
18 | },2000)
|
---|
19 | }
|
---|
20 |
|
---|
21 | export default triggerMapSave; |
---|
Note:
See
TracBrowser
for help on using the repository browser.