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

34
LINES

< > BotCompany Repo | #1015971 - dm_fieldLiveValue - live-value for a field in DynModule. TODO: adapt/test for transient fields

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

Libraryless. Click here for Pure Java version (10130L/72K).

static SimpleLiveValue dm_fieldLiveValue(S fieldName) {
  ret dm_fieldLiveValue(dm_current_mandatory(), fieldName);
}

static SimpleLiveValue dm_fieldLiveValue(final DynModule module, fS fieldName) {
  lock module.lock;
  temp module.enter(); // for dm_watchField
  Class type = getFieldType(module, fieldName);
  final SimpleLiveValue value = new(type, get(module, fieldName));
  dm_watchField(fieldName, r {
    ifdef dm_fieldLiveValue_debug
      print("dm_fieldLiveValue: setting " + fieldName);
    endifdef
    O o = get(module, fieldName);
    ifdef dm_fieldLiveValue_debug
      print("dm_fieldLiveValue: setting " + fieldName + " = " + o);
    endifdef
    value.set(o);
    ifdef dm_fieldLiveValue_debug
      print("dm_fieldLiveValue: setting " + fieldName + " done");
      printStackTrace();
    endifdef
  });
  value.onChange(r {
    ifdef dm_fieldLiveValue_debug
      print("dm_fieldLiveValue: setting 2 " + fieldName + " = " + value!);
    endifdef
    module.setField(fieldName, value!);
    ifdef dm_fieldLiveValue_debug
      print("dm_fieldLiveValue: setting 2 " + fieldName + " done");
    endifdef
  });
  ret value;
}

download  show line numbers  debug dex   

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

No comments. add comment

Snippet ID: #1015971
Snippet name: dm_fieldLiveValue - live-value for a field in DynModule. TODO: adapt/test for transient fields
Eternal ID of this version: #1015971/12
Text MD5: 71566e20128347ae60dd498acffa69c4
Transpilation MD5: abf1ad9c7eb0b76b19e90336154f4502
Author: stefan
Category: javax / stefan's os
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-02-03 17:59:48
Source code size: 1175 bytes / 34 lines
Pitched / IR pitched: No / No
Views / Downloads: 216 / 266
Version history: 11 change(s)
Referenced in: [show references]

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