Libraryless. Click here for Pure Java version (10142L/56K).
sclass RSTVar<A> extends VarWithNotify<A> { IVF1<A> action; A lastSentValue; ReliableSingleThread rst = new(l0 update); volatile bool forceUpdate; *(IVF1<A> *action) { onChange(rst); } private void update { A value = get(); if (!eq(lastSentValue, value) || forceUpdate) { forceUpdate = false; lastSentValue = value; action?.get(value); } } void forceUpdate { set forceUpdate; rst.trigger(); } }
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): elmgxqgtpvxh, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1035510 |
Snippet name: | RSTVar - Variable with action using ReliableSingleThread (e.g. for always showing the latest image of a stream) |
Eternal ID of this version: | #1035510/7 |
Text MD5: | f2e0b81d0b60c50ab2c94719199c8671 |
Transpilation MD5: | 5471df5eab82d36b7fb38835c4b55bdf |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-08-20 18:47:53 |
Source code size: | 488 bytes / 24 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 155 / 238 |
Version history: | 6 change(s) |
Referenced in: | [show references] |