@alwatr/signal 1.1.2 → 2.0.1
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/CHANGELOG.md +179 -163
- package/context.d.ts +31 -0
- package/context.d.ts.map +1 -0
- package/context.js +40 -0
- package/context.js.map +1 -0
- package/index.d.ts +6 -9
- package/index.d.ts.map +1 -1
- package/index.js +5 -16
- package/index.js.map +1 -1
- package/multithread-context.d.ts +21 -0
- package/multithread-context.d.ts.map +1 -0
- package/multithread-context.js +50 -0
- package/multithread-context.js.map +1 -0
- package/observable.d.ts +47 -0
- package/observable.d.ts.map +1 -0
- package/observable.js +127 -0
- package/observable.js.map +1 -0
- package/package.json +9 -9
- package/signal.d.ts +19 -0
- package/signal.d.ts.map +1 -0
- package/signal.js +23 -0
- package/signal.js.map +1 -0
- package/simple-signal.d.ts +19 -0
- package/simple-signal.d.ts.map +1 -0
- package/simple-signal.js +23 -0
- package/simple-signal.js.map +1 -0
- package/type.d.ts +15 -126
- package/type.d.ts.map +1 -1
- package/type.js.map +1 -1
- package/command-handler.d.ts +0 -25
- package/command-handler.d.ts.map +0 -1
- package/command-handler.js +0 -24
- package/command-handler.js.map +0 -1
- package/command-trigger.d.ts +0 -64
- package/command-trigger.d.ts.map +0 -1
- package/command-trigger.js +0 -64
- package/command-trigger.js.map +0 -1
- package/context-consumer.d.ts +0 -124
- package/context-consumer.d.ts.map +0 -1
- package/context-consumer.js +0 -124
- package/context-consumer.js.map +0 -1
- package/context-provider.d.ts +0 -120
- package/context-provider.d.ts.map +0 -1
- package/context-provider.js +0 -120
- package/context-provider.js.map +0 -1
- package/core.d.ts +0 -181
- package/core.d.ts.map +0 -1
- package/core.js +0 -388
- package/core.js.map +0 -1
- package/event-listener.d.ts +0 -120
- package/event-listener.d.ts.map +0 -1
- package/event-listener.js +0 -120
- package/event-listener.js.map +0 -1
- package/event-trigger.d.ts +0 -76
- package/event-trigger.d.ts.map +0 -1
- package/event-trigger.js +0 -76
- package/event-trigger.js.map +0 -1
- package/requestable-context-consumer.d.ts +0 -60
- package/requestable-context-consumer.d.ts.map +0 -1
- package/requestable-context-consumer.js +0 -54
- package/requestable-context-consumer.js.map +0 -1
- package/requestable-context-provider.d.ts +0 -69
- package/requestable-context-provider.d.ts.map +0 -1
- package/requestable-context-provider.js +0 -63
- package/requestable-context-provider.js.map +0 -1
package/event-trigger.d.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import type { Stringifyable } from '@alwatr/type';
|
|
2
|
-
/**
|
|
3
|
-
* Event signal trigger/dispatcher interface.
|
|
4
|
-
*/
|
|
5
|
-
export declare const eventTrigger: {
|
|
6
|
-
/**
|
|
7
|
-
* Get last event dispatched detail.
|
|
8
|
-
*
|
|
9
|
-
* Return undefined if signal not dispatched before or expired.
|
|
10
|
-
*
|
|
11
|
-
* Example:
|
|
12
|
-
*
|
|
13
|
-
* ```ts
|
|
14
|
-
* const currentSize = eventTrigger.getLastDetail<ResizeType>('window-resize');
|
|
15
|
-
* if (currentSize === undefined) {
|
|
16
|
-
* // event-signal not dispatched yet
|
|
17
|
-
* }
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
readonly getLastDetail: <T extends Stringifyable>(signalId: string) => T | undefined;
|
|
21
|
-
/**
|
|
22
|
-
* Dispatch (send) signal to all listeners.
|
|
23
|
-
*
|
|
24
|
-
* Signal detail changed immediately without any debounce.
|
|
25
|
-
*
|
|
26
|
-
* Example:
|
|
27
|
-
*
|
|
28
|
-
* ```ts
|
|
29
|
-
* eventTrigger.dispatch<ResizeType>('window-resize', newSize);
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
readonly dispatch: <T_1 extends Stringifyable>(signalId: string, detail: T_1, options?: Partial<import("./type.js").DispatchOptions>) => void;
|
|
33
|
-
/**
|
|
34
|
-
* Bind this interface to special event.
|
|
35
|
-
*
|
|
36
|
-
* Example:
|
|
37
|
-
*
|
|
38
|
-
* ```ts
|
|
39
|
-
* const resizeEvent = eventTrigger.bind<ResizeType>('window-resize');
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
readonly bind: <T_2 extends Stringifyable>(eventId: string) => {
|
|
43
|
-
/**
|
|
44
|
-
* Event signal Id.
|
|
45
|
-
*/
|
|
46
|
-
readonly id: string;
|
|
47
|
-
/**
|
|
48
|
-
* Get last event dispatched detail.
|
|
49
|
-
*
|
|
50
|
-
* Return undefined if signal not dispatched before or expired.
|
|
51
|
-
*
|
|
52
|
-
* Example:
|
|
53
|
-
*
|
|
54
|
-
* ```ts
|
|
55
|
-
* const currentSize = resizeEvent.getLastDetail();
|
|
56
|
-
* if (currentSize === undefined) {
|
|
57
|
-
* // signal not dispatched yet
|
|
58
|
-
* }
|
|
59
|
-
* ```
|
|
60
|
-
*/
|
|
61
|
-
readonly getLastDetail: () => T_2 | undefined;
|
|
62
|
-
/**
|
|
63
|
-
* Dispatch (send) signal to all listeners.
|
|
64
|
-
*
|
|
65
|
-
* Signal detail changed immediately without any debounce.
|
|
66
|
-
*
|
|
67
|
-
* Example:
|
|
68
|
-
*
|
|
69
|
-
* ```ts
|
|
70
|
-
* resizeEvent.dispatch(newSize);
|
|
71
|
-
* ```
|
|
72
|
-
*/
|
|
73
|
-
readonly dispatch: (detail: T_2, options?: Partial<import("./type.js").DispatchOptions> | undefined) => void;
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
//# sourceMappingURL=event-trigger.d.ts.map
|
package/event-trigger.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"event-trigger.d.ts","sourceRoot":"","sources":["src/event-trigger.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,aAAa,EAAiB,MAAM,cAAc,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,YAAY;IACvB;;;;;;;;;;;;;OAaG;;IAGH;;;;;;;;;;OAUG;;IAGH;;;;;;;;OAQG;wDACsC,MAAM;QAC7C;;WAEG;;QAGH;;;;;;;;;;;;;WAaG;;QAGH;;;;;;;;;;WAUG;;;CAGG,CAAC"}
|
package/event-trigger.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { dispatch, getDetail } from './core.js';
|
|
2
|
-
/**
|
|
3
|
-
* Event signal trigger/dispatcher interface.
|
|
4
|
-
*/
|
|
5
|
-
export const eventTrigger = {
|
|
6
|
-
/**
|
|
7
|
-
* Get last event dispatched detail.
|
|
8
|
-
*
|
|
9
|
-
* Return undefined if signal not dispatched before or expired.
|
|
10
|
-
*
|
|
11
|
-
* Example:
|
|
12
|
-
*
|
|
13
|
-
* ```ts
|
|
14
|
-
* const currentSize = eventTrigger.getLastDetail<ResizeType>('window-resize');
|
|
15
|
-
* if (currentSize === undefined) {
|
|
16
|
-
* // event-signal not dispatched yet
|
|
17
|
-
* }
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
getLastDetail: getDetail,
|
|
21
|
-
/**
|
|
22
|
-
* Dispatch (send) signal to all listeners.
|
|
23
|
-
*
|
|
24
|
-
* Signal detail changed immediately without any debounce.
|
|
25
|
-
*
|
|
26
|
-
* Example:
|
|
27
|
-
*
|
|
28
|
-
* ```ts
|
|
29
|
-
* eventTrigger.dispatch<ResizeType>('window-resize', newSize);
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
dispatch: dispatch,
|
|
33
|
-
/**
|
|
34
|
-
* Bind this interface to special event.
|
|
35
|
-
*
|
|
36
|
-
* Example:
|
|
37
|
-
*
|
|
38
|
-
* ```ts
|
|
39
|
-
* const resizeEvent = eventTrigger.bind<ResizeType>('window-resize');
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
bind: (eventId) => ({
|
|
43
|
-
/**
|
|
44
|
-
* Event signal Id.
|
|
45
|
-
*/
|
|
46
|
-
id: eventId,
|
|
47
|
-
/**
|
|
48
|
-
* Get last event dispatched detail.
|
|
49
|
-
*
|
|
50
|
-
* Return undefined if signal not dispatched before or expired.
|
|
51
|
-
*
|
|
52
|
-
* Example:
|
|
53
|
-
*
|
|
54
|
-
* ```ts
|
|
55
|
-
* const currentSize = resizeEvent.getLastDetail();
|
|
56
|
-
* if (currentSize === undefined) {
|
|
57
|
-
* // signal not dispatched yet
|
|
58
|
-
* }
|
|
59
|
-
* ```
|
|
60
|
-
*/
|
|
61
|
-
getLastDetail: getDetail.bind(null, eventId),
|
|
62
|
-
/**
|
|
63
|
-
* Dispatch (send) signal to all listeners.
|
|
64
|
-
*
|
|
65
|
-
* Signal detail changed immediately without any debounce.
|
|
66
|
-
*
|
|
67
|
-
* Example:
|
|
68
|
-
*
|
|
69
|
-
* ```ts
|
|
70
|
-
* resizeEvent.dispatch(newSize);
|
|
71
|
-
* ```
|
|
72
|
-
*/
|
|
73
|
-
dispatch: dispatch.bind(null, eventId),
|
|
74
|
-
}),
|
|
75
|
-
};
|
|
76
|
-
//# sourceMappingURL=event-trigger.js.map
|
package/event-trigger.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"event-trigger.js","sourceRoot":"","sources":["src/event-trigger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,SAAS,EAAC,MAAM,WAAW,CAAC;AAI9C;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B;;;;;;;;;;;;;OAaG;IACH,aAAa,EAAE,SAAS;IAExB;;;;;;;;;;OAUG;IACH,QAAQ,EAAE,QAAQ;IAElB;;;;;;;;OAQG;IACH,IAAI,EAAE,CAA0B,OAAe,EAAE,EAAE,CAAA,CAAC;QAClD;;WAEG;QACH,EAAE,EAAE,OAAO;QAEX;;;;;;;;;;;;;WAaG;QACH,aAAa,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAwC;QAEnF;;;;;;;;;;WAUG;QACH,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAuC;KACnE,CAAA;CACH,CAAC","sourcesContent":["import {dispatch, getDetail} from './core.js';\n\nimport type {Stringifyable, OmitFirstParam} from '@alwatr/type';\n\n/**\n * Event signal trigger/dispatcher interface.\n */\nexport const eventTrigger = {\n /**\n * Get last event dispatched detail.\n *\n * Return undefined if signal not dispatched before or expired.\n *\n * Example:\n *\n * ```ts\n * const currentSize = eventTrigger.getLastDetail<ResizeType>('window-resize');\n * if (currentSize === undefined) {\n * // event-signal not dispatched yet\n * }\n * ```\n */\n getLastDetail: getDetail,\n\n /**\n * Dispatch (send) signal to all listeners.\n *\n * Signal detail changed immediately without any debounce.\n *\n * Example:\n *\n * ```ts\n * eventTrigger.dispatch<ResizeType>('window-resize', newSize);\n * ```\n */\n dispatch: dispatch,\n\n /**\n * Bind this interface to special event.\n *\n * Example:\n *\n * ```ts\n * const resizeEvent = eventTrigger.bind<ResizeType>('window-resize');\n * ```\n */\n bind: <T extends Stringifyable>(eventId: string) =>({\n /**\n * Event signal Id.\n */\n id: eventId,\n\n /**\n * Get last event dispatched detail.\n *\n * Return undefined if signal not dispatched before or expired.\n *\n * Example:\n *\n * ```ts\n * const currentSize = resizeEvent.getLastDetail();\n * if (currentSize === undefined) {\n * // signal not dispatched yet\n * }\n * ```\n */\n getLastDetail: getDetail.bind(null, eventId) as OmitFirstParam<typeof getDetail<T>>,\n\n /**\n * Dispatch (send) signal to all listeners.\n *\n * Signal detail changed immediately without any debounce.\n *\n * Example:\n *\n * ```ts\n * resizeEvent.dispatch(newSize);\n * ```\n */\n dispatch: dispatch.bind(null, eventId) as OmitFirstParam<typeof dispatch<T>>,\n } as const),\n} as const;\n"]}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { RequestableContext } from './type.js';
|
|
2
|
-
import type { Stringifyable } from '@alwatr/type';
|
|
3
|
-
/**
|
|
4
|
-
* Requestable context consumer interface.
|
|
5
|
-
*/
|
|
6
|
-
export declare const requestableContextConsumer: {
|
|
7
|
-
/**
|
|
8
|
-
* Send new context request to the provider.
|
|
9
|
-
*
|
|
10
|
-
* Example:
|
|
11
|
-
*
|
|
12
|
-
* ```ts
|
|
13
|
-
* requestableContextConsumer.request<RequestParamType>('product-list', {foo: 'bar'});
|
|
14
|
-
* TODO: update me
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
readonly request: <TRequest extends Stringifyable>(contextId: string, requestParam: TRequest, options?: Partial<import("./type.js").DispatchOptions>) => void;
|
|
18
|
-
/**
|
|
19
|
-
* Bind this interface to special context.
|
|
20
|
-
*
|
|
21
|
-
* Example:
|
|
22
|
-
*
|
|
23
|
-
* ```ts
|
|
24
|
-
* const productListConsumer = requestableContextConsumer.bind<ProductListType>('product-list');
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
readonly bind: <TContextContent extends Stringifyable, TRquest extends Stringifyable = null>(contextId: string) => {
|
|
28
|
-
/**
|
|
29
|
-
* Get context value.
|
|
30
|
-
*
|
|
31
|
-
* Example:
|
|
32
|
-
*
|
|
33
|
-
* ```ts
|
|
34
|
-
* const currentProductList = productListConsumer.getValue();
|
|
35
|
-
* TODO: update me
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
readonly getValue: () => RequestableContext<TContextContent>;
|
|
39
|
-
/**
|
|
40
|
-
* Send new context request to the provider.
|
|
41
|
-
*
|
|
42
|
-
* Example:
|
|
43
|
-
*
|
|
44
|
-
* ```ts
|
|
45
|
-
* productListConsumer.request({foo: 'bar'});
|
|
46
|
-
* TODO: update me
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
readonly request: (requestParam: TRquest, options?: Partial<import("./type.js").DispatchOptions> | undefined) => void;
|
|
50
|
-
readonly id: string;
|
|
51
|
-
readonly untilChange: () => Promise<RequestableContext<TContextContent>>;
|
|
52
|
-
readonly subscribe: (listenerCallback: import("./type.js").ListenerFunction<RequestableContext<TContextContent>>, options?: Partial<import("./type.js").SubscribeOptions> | undefined) => import("./type.js").ListenerSpec;
|
|
53
|
-
readonly unsubscribe: (listener: import("./type.js").ListenerSpec) => void;
|
|
54
|
-
};
|
|
55
|
-
readonly getValue: <T extends Stringifyable>(signalId: string) => T | undefined;
|
|
56
|
-
readonly untilChange: <T_1 extends Stringifyable>(signalId: string) => Promise<T_1>;
|
|
57
|
-
readonly subscribe: <T_2 extends Stringifyable>(signalId: string, listenerCallback: import("./type.js").ListenerFunction<T_2>, options?: Partial<import("./type.js").SubscribeOptions>) => import("./type.js").ListenerSpec;
|
|
58
|
-
readonly unsubscribe: (listener: import("./type.js").ListenerSpec) => void;
|
|
59
|
-
};
|
|
60
|
-
//# sourceMappingURL=requestable-context-consumer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"requestable-context-consumer.d.ts","sourceRoot":"","sources":["src/requestable-context-consumer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,kBAAkB,EAAC,MAAM,WAAW,CAAC;AAE7C,OAAO,KAAK,EAAC,aAAa,EAAiB,MAAM,cAAc,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,0BAA0B;IAGrC;;;;;;;;;OASG;;IAGH;;;;;;;;OAQG;4GAC4F,MAAM;QAGnG;;;;;;;;;WASG;;QAIH;;;;;;;;;WASG;;;;;;;;;;;CAIG,CAAC"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { contextConsumer } from './context-consumer.js';
|
|
2
|
-
import { getDetail, requestContext } from './core.js';
|
|
3
|
-
/**
|
|
4
|
-
* Requestable context consumer interface.
|
|
5
|
-
*/
|
|
6
|
-
export const requestableContextConsumer = {
|
|
7
|
-
...contextConsumer,
|
|
8
|
-
/**
|
|
9
|
-
* Send new context request to the provider.
|
|
10
|
-
*
|
|
11
|
-
* Example:
|
|
12
|
-
*
|
|
13
|
-
* ```ts
|
|
14
|
-
* requestableContextConsumer.request<RequestParamType>('product-list', {foo: 'bar'});
|
|
15
|
-
* TODO: update me
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
request: requestContext,
|
|
19
|
-
/**
|
|
20
|
-
* Bind this interface to special context.
|
|
21
|
-
*
|
|
22
|
-
* Example:
|
|
23
|
-
*
|
|
24
|
-
* ```ts
|
|
25
|
-
* const productListConsumer = requestableContextConsumer.bind<ProductListType>('product-list');
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
bind: (contextId) => ({
|
|
29
|
-
...contextConsumer.bind(contextId),
|
|
30
|
-
/**
|
|
31
|
-
* Get context value.
|
|
32
|
-
*
|
|
33
|
-
* Example:
|
|
34
|
-
*
|
|
35
|
-
* ```ts
|
|
36
|
-
* const currentProductList = productListConsumer.getValue();
|
|
37
|
-
* TODO: update me
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
getValue: () => getDetail(contextId) ?? { state: 'initial' },
|
|
41
|
-
/**
|
|
42
|
-
* Send new context request to the provider.
|
|
43
|
-
*
|
|
44
|
-
* Example:
|
|
45
|
-
*
|
|
46
|
-
* ```ts
|
|
47
|
-
* productListConsumer.request({foo: 'bar'});
|
|
48
|
-
* TODO: update me
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
request: requestContext.bind(null, contextId),
|
|
52
|
-
}),
|
|
53
|
-
};
|
|
54
|
-
//# sourceMappingURL=requestable-context-consumer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"requestable-context-consumer.js","sourceRoot":"","sources":["src/requestable-context-consumer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAC,SAAS,EAAE,cAAc,EAAC,MAAM,WAAW,CAAC;AAKpD;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,GAAG,eAAe;IAElB;;;;;;;;;OASG;IACH,OAAO,EAAE,cAAc;IAEvB;;;;;;;;OAQG;IACH,IAAI,EAAE,CAA8E,SAAiB,EAAE,EAAE,CAAA,CAAC;QACxG,GAAG,eAAe,CAAC,IAAI,CAAsC,SAAS,CAAC;QAEvE;;;;;;;;;WASG;QACH,QAAQ,EAAE,GAAwC,EAAE,CAClD,SAAS,CAAsC,SAAS,CAAC,IAAI,EAAC,KAAK,EAAE,SAAS,EAAC;QAEjF;;;;;;;;;WASG;QACH,OAAO,EAAE,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CACI;KACvC,CAAA;CACH,CAAC","sourcesContent":["import {contextConsumer} from './context-consumer.js';\nimport {getDetail, requestContext} from './core.js';\nimport {RequestableContext} from './type.js';\n\nimport type {Stringifyable, OmitFirstParam} from '@alwatr/type';\n\n/**\n * Requestable context consumer interface.\n */\nexport const requestableContextConsumer = {\n ...contextConsumer,\n\n /**\n * Send new context request to the provider.\n *\n * Example:\n *\n * ```ts\n * requestableContextConsumer.request<RequestParamType>('product-list', {foo: 'bar'});\n * TODO: update me\n * ```\n */\n request: requestContext,\n\n /**\n * Bind this interface to special context.\n *\n * Example:\n *\n * ```ts\n * const productListConsumer = requestableContextConsumer.bind<ProductListType>('product-list');\n * ```\n */\n bind: <TContextContent extends Stringifyable, TRquest extends Stringifyable = null>(contextId: string) =>({\n ...contextConsumer.bind<RequestableContext<TContextContent>>(contextId),\n\n /**\n * Get context value.\n *\n * Example:\n *\n * ```ts\n * const currentProductList = productListConsumer.getValue();\n * TODO: update me\n * ```\n */\n getValue: (): RequestableContext<TContextContent> =>\n getDetail<RequestableContext<TContextContent>>(contextId) ?? {state: 'initial'},\n\n /**\n * Send new context request to the provider.\n *\n * Example:\n *\n * ```ts\n * productListConsumer.request({foo: 'bar'});\n * TODO: update me\n * ```\n */\n request: requestContext.bind(null, contextId) as\n OmitFirstParam<typeof requestContext<TRquest>>,\n } as const),\n} as const;\n"]}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { RequestableContext } from './type.js';
|
|
2
|
-
import type { Stringifyable } from '@alwatr/type';
|
|
3
|
-
/**
|
|
4
|
-
* Requestable context provider interface.
|
|
5
|
-
*/
|
|
6
|
-
export declare const requestableContextProvider: {
|
|
7
|
-
/**
|
|
8
|
-
* Defines the provider of the context signal that will be called when the context requested.
|
|
9
|
-
*
|
|
10
|
-
* subscribe to request context signal.
|
|
11
|
-
*
|
|
12
|
-
* Example:
|
|
13
|
-
*
|
|
14
|
-
* ```ts
|
|
15
|
-
* requestableContextProvider.setProvider<ProductListType, RequestParamType>(
|
|
16
|
-
* 'product-list',
|
|
17
|
-
* async (requestParam) => {
|
|
18
|
-
* return await fetchNewProductList(requestParam)
|
|
19
|
-
* },
|
|
20
|
-
* );
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
readonly setProvider: <TContext extends Stringifyable, TRquest extends Stringifyable = null>(signalId: string, signalProvider: import("./type.js").ProviderFunction<TRquest, void | TContext>, options?: Partial<import("./type.js").ProviderOptions>) => void;
|
|
24
|
-
/**
|
|
25
|
-
* Bind this interface to special context.
|
|
26
|
-
*
|
|
27
|
-
* Example:
|
|
28
|
-
*
|
|
29
|
-
* ```ts
|
|
30
|
-
* const productListProvider = requestableContextProvider.bind<ProductListType>('product-list');
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
readonly bind: <TContextContent extends Stringifyable, TRquest_1 extends Stringifyable = null>(contextId: string) => {
|
|
34
|
-
/**
|
|
35
|
-
* Get context value.
|
|
36
|
-
*
|
|
37
|
-
* Example:
|
|
38
|
-
*
|
|
39
|
-
* ```ts
|
|
40
|
-
* const currentProductList = productListConsumer.getValue();
|
|
41
|
-
* TODO: update me
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
readonly getValue: () => RequestableContext<TContextContent>;
|
|
45
|
-
/**
|
|
46
|
-
* Defines the provider of the context signal that will be called when the context requested.
|
|
47
|
-
*
|
|
48
|
-
* subscribe to request context signal.
|
|
49
|
-
*
|
|
50
|
-
* Example:
|
|
51
|
-
*
|
|
52
|
-
* ```ts
|
|
53
|
-
* productListProvider.setProvider(async (requestParam) => {
|
|
54
|
-
* return await fetchNewProductList(requestParam)
|
|
55
|
-
* });
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
readonly setProvider: (signalProvider: import("./type.js").ProviderFunction<TRquest_1, void | RequestableContext<TContextContent>>, options?: Partial<import("./type.js").ProviderOptions> | undefined) => void;
|
|
59
|
-
readonly id: string;
|
|
60
|
-
readonly setValue: (detail: RequestableContext<TContextContent>, options?: Partial<import("./type.js").DispatchOptions> | undefined) => void;
|
|
61
|
-
readonly expire: () => void;
|
|
62
|
-
readonly untilChange: () => Promise<RequestableContext<TContextContent>>;
|
|
63
|
-
};
|
|
64
|
-
readonly getValue: <T extends Stringifyable>(signalId: string) => T | undefined;
|
|
65
|
-
readonly setValue: <T_1 extends Stringifyable>(signalId: string, detail: T_1, options?: Partial<import("./type.js").DispatchOptions>) => void;
|
|
66
|
-
readonly expire: (signalId: string) => void;
|
|
67
|
-
readonly untilChange: <T_2 extends Stringifyable>(signalId: string) => Promise<T_2>;
|
|
68
|
-
};
|
|
69
|
-
//# sourceMappingURL=requestable-context-provider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"requestable-context-provider.d.ts","sourceRoot":"","sources":["src/requestable-context-provider.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,kBAAkB,EAAC,MAAM,WAAW,CAAC;AAE7C,OAAO,KAAK,EAAC,aAAa,EAAiB,MAAM,cAAc,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,0BAA0B;IAGrC;;;;;;;;;;;;;;;OAeG;;IAGH;;;;;;;;OAQG;8GAC4F,MAAM;QAGnG;;;;;;;;;WASG;;QAKH;;;;;;;;;;;;WAYG;;;;;;;;;;;CAIG,CAAC"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { contextProvider } from './context-provider.js';
|
|
2
|
-
import { getDetail, setContextProvider } from './core.js';
|
|
3
|
-
/**
|
|
4
|
-
* Requestable context provider interface.
|
|
5
|
-
*/
|
|
6
|
-
export const requestableContextProvider = {
|
|
7
|
-
...contextProvider,
|
|
8
|
-
/**
|
|
9
|
-
* Defines the provider of the context signal that will be called when the context requested.
|
|
10
|
-
*
|
|
11
|
-
* subscribe to request context signal.
|
|
12
|
-
*
|
|
13
|
-
* Example:
|
|
14
|
-
*
|
|
15
|
-
* ```ts
|
|
16
|
-
* requestableContextProvider.setProvider<ProductListType, RequestParamType>(
|
|
17
|
-
* 'product-list',
|
|
18
|
-
* async (requestParam) => {
|
|
19
|
-
* return await fetchNewProductList(requestParam)
|
|
20
|
-
* },
|
|
21
|
-
* );
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
setProvider: setContextProvider,
|
|
25
|
-
/**
|
|
26
|
-
* Bind this interface to special context.
|
|
27
|
-
*
|
|
28
|
-
* Example:
|
|
29
|
-
*
|
|
30
|
-
* ```ts
|
|
31
|
-
* const productListProvider = requestableContextProvider.bind<ProductListType>('product-list');
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
bind: (contextId) => ({
|
|
35
|
-
...contextProvider.bind(contextId),
|
|
36
|
-
/**
|
|
37
|
-
* Get context value.
|
|
38
|
-
*
|
|
39
|
-
* Example:
|
|
40
|
-
*
|
|
41
|
-
* ```ts
|
|
42
|
-
* const currentProductList = productListConsumer.getValue();
|
|
43
|
-
* TODO: update me
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
|
-
getValue: () => getDetail(contextId) ?? { state: 'initial' },
|
|
47
|
-
/**
|
|
48
|
-
* Defines the provider of the context signal that will be called when the context requested.
|
|
49
|
-
*
|
|
50
|
-
* subscribe to request context signal.
|
|
51
|
-
*
|
|
52
|
-
* Example:
|
|
53
|
-
*
|
|
54
|
-
* ```ts
|
|
55
|
-
* productListProvider.setProvider(async (requestParam) => {
|
|
56
|
-
* return await fetchNewProductList(requestParam)
|
|
57
|
-
* });
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
setProvider: setContextProvider.bind(null, contextId),
|
|
61
|
-
}),
|
|
62
|
-
};
|
|
63
|
-
//# sourceMappingURL=requestable-context-provider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"requestable-context-provider.js","sourceRoot":"","sources":["src/requestable-context-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAC,SAAS,EAAE,kBAAkB,EAAC,MAAM,WAAW,CAAC;AAKxD;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,GAAG,eAAe;IAElB;;;;;;;;;;;;;;;OAeG;IACH,WAAW,EAAE,kBAAkB;IAE/B;;;;;;;;OAQG;IACH,IAAI,EAAE,CAA8E,SAAiB,EAAE,EAAE,CAAA,CAAC;QACxG,GAAG,eAAe,CAAC,IAAI,CAAsC,SAAS,CAAC;QAEvE;;;;;;;;;WASG;QACH,QAAQ,EAAE,GAAwC,EAAE,CAClD,SAAS,CAAsC,SAAS,CAAC,IAAI,EAAC,KAAK,EAAE,SAAS,EAAC;QAGjF;;;;;;;;;;;;WAYG;QACH,WAAW,EAAE,kBAAkB,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CACqC;KAChF,CAAA;CACH,CAAC","sourcesContent":["import {contextProvider} from './context-provider.js';\nimport {getDetail, setContextProvider} from './core.js';\nimport {RequestableContext} from './type.js';\n\nimport type {Stringifyable, OmitFirstParam} from '@alwatr/type';\n\n/**\n * Requestable context provider interface.\n */\nexport const requestableContextProvider = {\n ...contextProvider,\n\n /**\n * Defines the provider of the context signal that will be called when the context requested.\n *\n * subscribe to request context signal.\n *\n * Example:\n *\n * ```ts\n * requestableContextProvider.setProvider<ProductListType, RequestParamType>(\n * 'product-list',\n * async (requestParam) => {\n * return await fetchNewProductList(requestParam)\n * },\n * );\n * ```\n */\n setProvider: setContextProvider,\n\n /**\n * Bind this interface to special context.\n *\n * Example:\n *\n * ```ts\n * const productListProvider = requestableContextProvider.bind<ProductListType>('product-list');\n * ```\n */\n bind: <TContextContent extends Stringifyable, TRquest extends Stringifyable = null>(contextId: string) =>({\n ...contextProvider.bind<RequestableContext<TContextContent>>(contextId),\n\n /**\n * Get context value.\n *\n * Example:\n *\n * ```ts\n * const currentProductList = productListConsumer.getValue();\n * TODO: update me\n * ```\n */\n getValue: (): RequestableContext<TContextContent> =>\n getDetail<RequestableContext<TContextContent>>(contextId) ?? {state: 'initial'},\n\n\n /**\n * Defines the provider of the context signal that will be called when the context requested.\n *\n * subscribe to request context signal.\n *\n * Example:\n *\n * ```ts\n * productListProvider.setProvider(async (requestParam) => {\n * return await fetchNewProductList(requestParam)\n * });\n * ```\n */\n setProvider: setContextProvider.bind(null, contextId) as\n OmitFirstParam<typeof setContextProvider<RequestableContext<TContextContent>, TRquest>>,\n } as const),\n} as const;\n"]}
|