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

15
LINES

< > BotCompany Repo | #1017440 // onValueChange - monitor a value regularly

JavaX fragment (include)

// f : func -> A
// onChange: voidfunc(A) or Runnable
static java.util.Timer onValueChange(int interval, fO f, fO onChange) {
  ret doEvery(interval, new Runnable {
    O lastValue = pcallF(f);
    
    public void run {
      O value = pcallF(f);
      if (neq(value, lastValue)) {
        lastValue = value;
        callF(onChange, value);
      }
    }
  });
}

Author comment

Began life as a copy of #1017370

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1017440
Snippet name: onValueChange - monitor a value regularly
Eternal ID of this version: #1017440/3
Text MD5: f4938fc8633e43a929202d1a31f5485c
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-07-22 09:28:13
Source code size: 377 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 389 / 411
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)