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   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pzhvpgtvlbxg, tvejysmllsmz

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

Formerly at http://tinybrain.de/1024376 & http://1024376.tinybrain.de