Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

19
LINES

< > BotCompany Repo | #1015834 // NotTooOften

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (4582L/25K).

1  
sclass NotTooOften {
2  
  long minDelay;
3  
  long lastTime;
4  
  
5  
  *() {}
6  
  *(long *minDelay) {}
7  
  *(double minSeconds) { minDelay = toMS(minSeconds); }
8  
  
9  
  bool canDoAgain_willDoIfTrue aka yo aka get() {
10  
    ping();
11  
    if (lastTime == 0 || now() >= lastTime+minDelay)
12  
      ret true with lastTime = now();
13  
    false;
14  
  }
15  
  
16  
  void dO(Runnable r) {
17  
    if (get()) r?.run();
18  
  }
19  
}

Author comment

Began life as a copy of #1006309

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ekrmjmnbrukm, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1015834
Snippet name: NotTooOften
Eternal ID of this version: #1015834/8
Text MD5: c87ebff5636fb56ab63fcf5f4c5bb53d
Transpilation MD5: 3d03ce7744ad62d4422926e59928de58
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-01 21:31:46
Source code size: 392 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 488 / 1188
Version history: 7 change(s)
Referenced in: [show references]