source: imaps-frontend/src/scripts/util/triggerMapSave.js@ 0c6b92a

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
RevLine 
[0c6b92a]1let canSave = true;
2const mapSaveEvent = new CustomEvent("mapsave",{});
3const 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 */
10const 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
21export default triggerMapSave;
Note: See TracBrowser for help on using the repository browser.