Uses 911K of libraries. Click here for Pure Java version (2620L/14K).
1 | !7 |
2 | |
3 | sclass Prop { |
4 | S text, module; |
5 | Runnable action; |
6 | long date = now(); |
7 | |
8 | [stdEq] |
9 | } |
10 | |
11 | cmodule ProposedActions > DynObjectTable<Prop> { |
12 | transient int expiryTime = 10000; |
13 | transient long timer; // When we began thinking |
14 | transient int thinkTime = 2000; |
15 | |
16 | start { |
17 | dontPersist(); // can't persist foreign Runnables |
18 | //doEvery(1000, r cleanList); |
19 | } |
20 | |
21 | void addProposition(S text, Runnable action, S module) { |
22 | add(nu(Prop, +text, +action, +module)); |
23 | } |
24 | |
25 | void cleanList { |
26 | setField(data := objectsWhereFieldGreaterThan(cloneList(data), date := now()-expiryTime)); |
27 | if (syncNempty(data)) { |
28 | if (timer == 0) timer = now(); |
29 | if (now() >= timer+thinkTime) { |
30 | S out = getString(random(data), 'text); |
31 | clear(); |
32 | timer = 0; |
33 | } |
34 | } |
35 | } |
36 | } |
Began life as a copy of #1016982
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1027426 |
Snippet name: | Proposed Actions [dev.] |
Eternal ID of this version: | #1027426/4 |
Text MD5: | 5ffeee8fd4b0ebd7795300efd60a3d7a |
Transpilation MD5: | 3171e1f4e1ed9bfcc898fab9827435c5 |
Author: | stefan |
Category: | javax / dynamic modules |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-03-18 20:00:45 |
Source code size: | 834 bytes / 36 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 181 / 381 |
Version history: | 3 change(s) |
Referenced in: | [show references] |