smsmslib 1.0.21 → 1.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smsmslib",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "description": "Reusable functions for me.",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -15,8 +15,9 @@ export function sj_reducer_use(hf_type, init, f_init, user)
15
15
 
16
16
  function sj_reducer_onAction_use(hf_type, f_dispatch, user)
17
17
  {
18
- const f_onAction = sj_memo_use(sj_reducer_onAction_create,
19
- [hf_type, f_dispatch, user], [hf_type, user]);
18
+ const a_arg = [hf_type, f_dispatch, user];
19
+ const a_dep = [hf_type, user];
20
+ const f_onAction = sj_memo_use(sj_reducer_onAction_create, a_arg, a_dep);
20
21
 
21
22
  return f_onAction;
22
23
  }
@@ -36,11 +37,12 @@ function sj_reducer_onAction_create(hf_type, f_dispatch, user)
36
37
  {
37
38
  const o_action =
38
39
  {
39
- type : s_type, /* By convention. */
40
+ type: s_type, /* By convention. */
40
41
  f_type, o_event, user,
41
42
 
42
- // pass the copy of o_event. Otherwise o_event.currentTarget will be null
43
+ // Pass the copy of o_event. Because o_event.currentTarget will be null
43
44
  // by the time sj_reducer() is called.
45
+ // Normally, refer to o_event with priority.
44
46
  o_event_bak: {...o_event},
45
47
  };
46
48
 
@@ -0,0 +1,44 @@
1
+ import {useRef} from "react";
2
+ import {sj_memo_use} from "smsmslib/system/usememo";
3
+
4
+
5
+ export function sj_ref_use(hf_type, init, user)
6
+ {
7
+ const o_ref = useRef(init);
8
+
9
+ o_ref.f_onAction = sj_ref_onAction_use(hf_type, o_ref, user);
10
+ return o_ref;
11
+ }
12
+
13
+
14
+ function sj_ref_onAction_use(hf_type, o_ref, user)
15
+ {
16
+ const a_arg = [hf_type, o_ref, user];
17
+ const a_dep = a_arg;
18
+ const f_onAction = sj_memo_use(sj_ref_onAction_create, a_arg, a_dep);
19
+
20
+ return f_onAction;
21
+ }
22
+
23
+
24
+ function sj_ref_onAction_create(hf_type, o_ref, user)
25
+ {
26
+ function onAction(o_event)
27
+ {
28
+ const s_type = o_event.currentTarget.dataset.s_type;
29
+
30
+ if (s_type in hf_type)
31
+ {
32
+ const f_type = hf_type[s_type];
33
+
34
+ if (f_type !== null)
35
+ {
36
+ f_type(o_ref, o_event, user);
37
+ }
38
+ }
39
+ }
40
+
41
+ return onAction;
42
+ }
43
+
44
+
package/tags_JavaScript CHANGED
@@ -10,6 +10,7 @@ Reducer_t_use /home/sakae/work/react/smsmslib/system/usereducer.js ?^function Re
10
10
  State_t /home/sakae/work/react/smsmslib/system/usestate.js ?^function State_t(value, f_onAction, user)$?;" f
11
11
  f_cal_caller /home/sakae/work/react/smsmslib/system/usememo.js ?^ function f_cal_caller()$?;" f
12
12
  onAction /home/sakae/work/react/smsmslib/system/usereducer.js ?^ function onAction(o_event)$?;" f
13
+ onAction /home/sakae/work/react/smsmslib/system/useref.js ?^ function onAction(o_event)$?;" f
13
14
  onAction /home/sakae/work/react/smsmslib/system/usestate.js ?^ function onAction(o_event)$?;" f
14
15
  sj_loop_for_ms /home/sakae/work/react/smsmslib/system/util.js ?^export function sj_loop_for_ms(i_ms)$?;" f
15
16
  sj_memo_use /home/sakae/work/react/smsmslib/system/usememo.js ?^export function sj_memo_use(f_cal, a_arg, a_dep)$?;" f
@@ -17,6 +18,9 @@ sj_reducer /home/sakae/work/react/smsmslib/system/usereducer.js ?^function sj_re
17
18
  sj_reducer_onAction_create /home/sakae/work/react/smsmslib/system/usereducer.js ?^function sj_reducer_onAction_create(hf_type, f_dispatch, user)$?;" f
18
19
  sj_reducer_onAction_use /home/sakae/work/react/smsmslib/system/usereducer.js ?^function sj_reducer_onAction_use(hf_type, f_dispatch, user)$?;" f
19
20
  sj_reducer_use /home/sakae/work/react/smsmslib/system/usereducer.js ?^export function sj_reducer_use(hf_type, init, f_init, user)$?;" f
21
+ sj_ref_onAction_create /home/sakae/work/react/smsmslib/system/useref.js ?^function sj_ref_onAction_create(hf_type, o_ref, user)$?;" f
22
+ sj_ref_onAction_use /home/sakae/work/react/smsmslib/system/useref.js ?^function sj_ref_onAction_use(hf_type, o_ref, user)$?;" f
23
+ sj_ref_use /home/sakae/work/react/smsmslib/system/useref.js ?^export function sj_ref_use(hf_type, init, user)$?;" f
20
24
  sj_state_onAction /home/sakae/work/react/smsmslib/system/usestate.js ?^export function sj_state_onAction(value, f_set, hf_type, user)$?;" f
21
25
  sj_state_use /home/sakae/work/react/smsmslib/system/usestate.js ?^export function sj_state_use(f_init, hf_type, user)$?;" f
22
26
  specified /home/sakae/work/react/smsmslib/system/usereducer.js ?^/* Don't use a hook inside the function specified in the argument f_init. */$?;" f