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

36
LINES

< > BotCompany Repo | #1015971 // dm_fieldLiveValue - live-value for a field in DynModule. should also work with transient fields

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

Libraryless. Compilation Failed (16746L/101K).

// TODO: use weak reference to live value - or make each of them only once

static SimpleLiveValue dm_fieldLiveValue(DynModule module default dm_current_mandatory(), S 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;
}

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

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1015971
Snippet name: dm_fieldLiveValue - live-value for a field in DynModule. should also work with transient fields
Eternal ID of this version: #1015971/19
Text MD5: 3347e7cafefa2ca274688b5d7dd1a50c
Transpilation MD5: 818ed4290d9711abe09efa8376e1507a
Author: stefan
Category: javax / stefan's os
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-29 04:20:00
Source code size: 1279 bytes / 36 lines
Pitched / IR pitched: No / No
Views / Downloads: 559 / 709
Version history: 18 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1016014 - dm_calculatedLiveValue - live-value for a calculation that is updated when DynModule changes
#1017058 - dm_fieldLiveValue_verbose - live-value for a field in DynModule
#1018359 - dm_fieldLiveValueWithNotify
#1018470 - dm_fieldLabel - label reflecting a module field
#1026955 - OLD version for persistent fields only. dm_fieldLiveValue - live-value for a field in DynModule
#1027315 - dm_fieldLiveValueWithConversions
#1031140 - conceptFieldLiveValue - LiveValue reflecting a concept's field. Not for Ref/RefL fields!