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

13
LINES

< > BotCompany Repo | #1024376 // rWatcher - wrap a Runnable & only run it if a value has changed. executes the first time

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

Libraryless. Click here for Pure Java version (1642L/11K).

static <A> Runnable rWatcher(IF0<A> calc, Runnable r) {
  ret new Runnable {
    A value;
    
    run {
      A newValue = callF(calc);
      if (neq(value, newValue)) {
        value = newValue;
        callF(r);
      }
    }
  };
}

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1024376
Snippet name: rWatcher - wrap a Runnable & only run it if a value has changed. executes the first time
Eternal ID of this version: #1024376/4
Text MD5: 6575c648a629d6464505991ae4358d02
Transpilation MD5: 96b299cafc87d94bd6a4a271c16546e7
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-08 14:28:08
Source code size: 247 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 257 / 337
Version history: 3 change(s)
Referenced in: [show references]