@vanyamate/sec 0.0.6 → 0.0.7
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/index.d.ts +2 -1
- package/index.ts +3 -2
- package/package.json +2 -2
- package/.idea/modules.xml +0 -8
- package/.idea/sec.iml +0 -12
- package/.idea/vcs.xml +0 -6
package/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type EffectFunction<Args extends any[], Result> = (...args: Args) => Promise<Result>;
|
|
2
|
+
export type EffectEvent = 'onBefore' | 'onSuccess' | 'onError' | 'onFinally';
|
|
2
3
|
export type Effect<Args extends any[], Result> = {
|
|
3
4
|
(...args: Args): Promise<Result>;
|
|
4
5
|
onSuccess: (callback: (result: Result, ...args: Args) => void) => void;
|
|
@@ -11,7 +12,7 @@ export declare function effect<Args extends any[], Result>(fn: EffectFunction<Ar
|
|
|
11
12
|
export type Store<State> = {
|
|
12
13
|
get: () => State;
|
|
13
14
|
set: (newState: State) => void;
|
|
14
|
-
on: <Args extends any[], Result>(effect: Effect<Args, Result>, event:
|
|
15
|
+
on: <Args extends any[], Result>(effect: Effect<Args, Result>, event: EffectEvent, handler: (state: State, payload: {
|
|
15
16
|
result?: Result;
|
|
16
17
|
error?: any;
|
|
17
18
|
meta: Args;
|
package/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type EffectFunction<Args extends any[], Result> = (...args: Args) => Promise<Result>;
|
|
2
|
+
export type EffectEvent = 'onBefore' | 'onSuccess' | 'onError' | 'onFinally';
|
|
2
3
|
|
|
3
4
|
export type Effect<Args extends any[], Result> = {
|
|
4
5
|
(...args: Args): Promise<Result>;
|
|
@@ -54,7 +55,7 @@ export type Store<State> = {
|
|
|
54
55
|
set: (newState: State) => void;
|
|
55
56
|
on: <Args extends any[], Result>(
|
|
56
57
|
effect: Effect<Args, Result>,
|
|
57
|
-
event:
|
|
58
|
+
event: EffectEvent,
|
|
58
59
|
handler: (state: State, payload: {
|
|
59
60
|
result?: Result;
|
|
60
61
|
error?: any;
|
|
@@ -76,7 +77,7 @@ export function store<State> (initialState: State): Store<State> {
|
|
|
76
77
|
|
|
77
78
|
const on = <Args extends any[], Result> (
|
|
78
79
|
effect: Effect<Args, Result>,
|
|
79
|
-
event:
|
|
80
|
+
event: EffectEvent,
|
|
80
81
|
handler: (state: State, payload: {
|
|
81
82
|
result?: Result;
|
|
82
83
|
error?: any;
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vanyamate/sec",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "SEC. Store, Effect, Combine. Tiny state manager",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"g:type": "tsc index.ts --declaration --emitDeclarationOnly"
|
|
7
7
|
},
|
|
8
|
-
"types": "index.d.ts",
|
|
8
|
+
"types": "./index.d.ts",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "git+https://github.com/VanyaMate/sec.git"
|
package/.idea/modules.xml
DELETED
package/.idea/sec.iml
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<module type="WEB_MODULE" version="4">
|
|
3
|
-
<component name="NewModuleRootManager">
|
|
4
|
-
<content url="file://$MODULE_DIR$">
|
|
5
|
-
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
6
|
-
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
7
|
-
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
8
|
-
</content>
|
|
9
|
-
<orderEntry type="inheritedJdk" />
|
|
10
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
|
11
|
-
</component>
|
|
12
|
-
</module>
|