smsmslib 1.0.2 → 1.0.4
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 +1 -1
- package/system/usereducer.js +57 -0
- package/system/usestate.js +43 -0
- package/tags_JavaScript +9 -0
package/package.json
CHANGED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {useReducer} from "react";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export function sj_reducer_use(hf_type, init, f_init, user)
|
|
5
|
+
{
|
|
6
|
+
const [value, f_dispatch] = useReducer(sj_reducer, init, f_init);
|
|
7
|
+
const f_onAction = sj_reducer_onAction(hf_type, f_dispatch, user);
|
|
8
|
+
const o_reducer = new Reducer_t(value, f_onAction, user);
|
|
9
|
+
|
|
10
|
+
return o_reducer;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
function sj_reducer_onAction(hf_type, f_dispatch, user)
|
|
15
|
+
{
|
|
16
|
+
function onAction(o_event)
|
|
17
|
+
{
|
|
18
|
+
const s_type = o_event.target.dataset.s_type;
|
|
19
|
+
|
|
20
|
+
if ((s_type in hf_type) && (f_dispatch !== null))
|
|
21
|
+
{
|
|
22
|
+
const f_type = hf_type[s_type];
|
|
23
|
+
|
|
24
|
+
if (f_type !== null)
|
|
25
|
+
{
|
|
26
|
+
const o_action =
|
|
27
|
+
{
|
|
28
|
+
type : s_type, /* By convention. */
|
|
29
|
+
f_type : f_type,
|
|
30
|
+
o_event: o_event,
|
|
31
|
+
user : user,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
f_dispatch(o_action);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return onAction;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
function sj_reducer(value, o_action)
|
|
44
|
+
{
|
|
45
|
+
const o_next = o_action.f_type(value, o_action.o_event, o_action.user);
|
|
46
|
+
return o_next;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
function Reducer_t(value, f_onAction, user)
|
|
51
|
+
{
|
|
52
|
+
this.value = value;
|
|
53
|
+
this.f_onAction = f_onAction;
|
|
54
|
+
this.user = user;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {useState} from "react";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export function sj_use_state(ini)
|
|
5
|
+
{
|
|
6
|
+
const [val, f_set] = useState(ini);
|
|
7
|
+
const o_ret = new State_t(val, f_set);
|
|
8
|
+
|
|
9
|
+
return o_ret;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
function State_t(value, f_set, f_onAction, o_user)
|
|
14
|
+
{
|
|
15
|
+
this.value = value;
|
|
16
|
+
this.f_set = f_set;
|
|
17
|
+
this.f_onAction = f_onAction;
|
|
18
|
+
this.o_user = o_user;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
export function sj_onAction_get(o_main)
|
|
23
|
+
{
|
|
24
|
+
function onAction(o_eve)
|
|
25
|
+
{
|
|
26
|
+
const o_update = o_main.o_update;
|
|
27
|
+
const s_type = o_eve.target.dataset.s_type;
|
|
28
|
+
|
|
29
|
+
if (s_type in o_update)
|
|
30
|
+
{
|
|
31
|
+
const ao_next = o_update[s_type](o_main, o_eve);
|
|
32
|
+
|
|
33
|
+
for (const o_next of ao_next)
|
|
34
|
+
{
|
|
35
|
+
o_next.f_set(o_next.val);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return onAction;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
package/tags_JavaScript
CHANGED
|
@@ -4,7 +4,16 @@
|
|
|
4
4
|
!_TAG_PROGRAM_NAME Exuberant Ctags //
|
|
5
5
|
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
|
|
6
6
|
!_TAG_PROGRAM_VERSION 5.9~svn20110310 //
|
|
7
|
+
Reducer_t /home/sakae/work/react/smsmslib/system/usereducer.js ?^function Reducer_t(value, f_onAction, user)$?;" f
|
|
7
8
|
State_t /home/sakae/work/react/smsmslib/system/proto.js ?^export function State_t(val, f_set)$?;" f
|
|
9
|
+
State_t /home/sakae/work/react/smsmslib/system/usestate.js ?^function State_t(value, f_set, f_onAction, o_user)$?;" f
|
|
8
10
|
onAction /home/sakae/work/react/smsmslib/system/proto.js ?^ function onAction(o_eve)$?;" f
|
|
11
|
+
onAction /home/sakae/work/react/smsmslib/system/usereducer.js ?^ function onAction(o_event)$?;" f
|
|
12
|
+
onAction /home/sakae/work/react/smsmslib/system/usestate.js ?^ function onAction(o_eve)$?;" f
|
|
9
13
|
sj_onAction_get /home/sakae/work/react/smsmslib/system/proto.js ?^export function sj_onAction_get(o_main)$?;" f
|
|
14
|
+
sj_onAction_get /home/sakae/work/react/smsmslib/system/usestate.js ?^export function sj_onAction_get(o_main)$?;" f
|
|
15
|
+
sj_reducer /home/sakae/work/react/smsmslib/system/usereducer.js ?^function sj_reducer(value, o_action)$?;" f
|
|
16
|
+
sj_reducer_onAction /home/sakae/work/react/smsmslib/system/usereducer.js ?^function sj_reducer_onAction(hf_type, f_dispatch, user)$?;" f
|
|
17
|
+
sj_reducer_use /home/sakae/work/react/smsmslib/system/usereducer.js ?^export function sj_reducer_use(hf_type, init, f_init, user)$?;" f
|
|
10
18
|
sj_use_state /home/sakae/work/react/smsmslib/system/proto.js ?^export function sj_use_state(ini)$?;" f
|
|
19
|
+
sj_use_state /home/sakae/work/react/smsmslib/system/usestate.js ?^export function sj_use_state(ini)$?;" f
|