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).

sclass NotTooOften {
  long minDelay;
  long lastTime;
  
  *() {}
  *(long *minDelay) {}
  *(double minSeconds) { minDelay = toMS(minSeconds); }
  
  bool canDoAgain_willDoIfTrue aka yo aka get() {
    ping();
    if (lastTime == 0 || now() >= lastTime+minDelay)
      ret true with lastTime = now();
    false;
  }
  
  void dO(Runnable r) {
    if (get()) r?.run();
  }
}

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: 322 / 927
Version history: 7 change(s)
Referenced in: [show references]