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

18
LINES

< > BotCompany Repo | #1025206 // lvFlexibleRateTimerFreq (two-way string live value for text fields)

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

Libraryless. Click here for Pure Java version (3708L/24K).

1  
static SimpleLiveValue<S> lvFlexibleRateTimerFreq(FlexibleRateTimer timer, O... _) {
2  
  SimpleLiveValue<S> lvRate = stringLiveValue();
3  
  optPar int delayOnInput = 1000; // how long to wait after someone typed a new frequency value (ms)
4  
  
5  
  embedded S formattedFrequency() {
6  
    ret formatDouble(timer.getFrequency(), 3);
7  
  }
8  
9  
  lvRate.onChange(rLater(delayOnInput, r {
10  
    S s = trim(lvRate!);
11  
    if (eq(s, formattedFrequency())) ret;
12  
    Double hz = parseDoubleOpt(s), ret if null;
13  
    timer.setFrequencyImmediately(hz);
14  
  }));
15  
  
16  
  timer.onFrequencyChangedAndNow(r{ lvRate.set(formattedFrequency()) });
17  
  ret lvRate;
18  
}

Author comment

Began life as a copy of #1025194

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: #1025206
Snippet name: lvFlexibleRateTimerFreq (two-way string live value for text fields)
Eternal ID of this version: #1025206/4
Text MD5: 60af49842bd794853de7bb09f12ad8c5
Transpilation MD5: 8e1fcb611e438922a91fc6da61573cfb
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-09-13 13:48:37
Source code size: 638 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 272 / 362
Version history: 3 change(s)
Referenced in: [show references]