live-cache 0.1.0 → 0.2.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/README.md +116 -72
- package/dist/core/Controller.d.ts +12 -5
- package/dist/core/Invalidator.d.ts +11 -0
- package/dist/core/ObjectStore.d.ts +5 -0
- package/dist/core/StorageManager.d.ts +10 -6
- package/dist/core/Transactions.d.ts +20 -0
- package/dist/index.cjs +242 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.mjs +239 -69
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +242 -68
- package/dist/index.umd.js.map +1 -1
- package/dist/invalidator/TimeoutInvalidator.d.ts +13 -0
- package/dist/invalidator/WebsocketInvalidator.d.ts +28 -0
- package/dist/react/useController.d.ts +6 -3
- package/dist/storage-manager/IndexDbStorageManager.d.ts +1 -1
- package/dist/storage-manager/LocalStorageManager.d.ts +1 -1
- package/package.json +5 -1
|
@@ -24,12 +24,15 @@ export interface UseControllerResult<TVariable, TName extends string> {
|
|
|
24
24
|
* @param where - optional `Collection.find()` filter (string `_id` or partial)
|
|
25
25
|
* @param options - store selection, initialise behavior, abort-on-unmount, and invalidation wiring
|
|
26
26
|
*
|
|
27
|
-
* When `options.withInvalidation` is true, this hook calls
|
|
28
|
-
*
|
|
27
|
+
* When `options.withInvalidation` is true, this hook calls
|
|
28
|
+
* `controller.invalidator.registerInvalidation()` on mount and
|
|
29
|
+
* `controller.invalidator.unregisterInvalidation()` on unmount.
|
|
29
30
|
*
|
|
30
31
|
* @example
|
|
31
32
|
* ```tsx
|
|
32
|
-
* const { data, controller } = useController<User, "users">("users"
|
|
33
|
+
* const { data, controller } = useController<User, "users">("users", undefined, {
|
|
34
|
+
* withInvalidation: true,
|
|
35
|
+
* });
|
|
33
36
|
* return (
|
|
34
37
|
* <button onClick={() => void controller.invalidate()}>Refresh</button>
|
|
35
38
|
* );
|
|
@@ -23,7 +23,6 @@ export interface IndexDbStorageManagerOptions {
|
|
|
23
23
|
export default class IndexDbStorageManager extends StorageManager<any> {
|
|
24
24
|
private dbName;
|
|
25
25
|
private storeName;
|
|
26
|
-
private prefix;
|
|
27
26
|
private dbPromise;
|
|
28
27
|
constructor(options?: IndexDbStorageManagerOptions);
|
|
29
28
|
private key;
|
|
@@ -34,4 +33,5 @@ export default class IndexDbStorageManager extends StorageManager<any> {
|
|
|
34
33
|
get<T>(name: string): Promise<T[]>;
|
|
35
34
|
set(name: string, models: any[]): Promise<void>;
|
|
36
35
|
delete(name: string): Promise<void>;
|
|
36
|
+
getParams(): Promise<string[]>;
|
|
37
37
|
}
|
|
@@ -6,10 +6,10 @@ import { StorageManager } from "../core/StorageManager";
|
|
|
6
6
|
* Reads return `[]` on failure (private mode, JSON parse issues, etc).
|
|
7
7
|
*/
|
|
8
8
|
export default class LocalStorageStorageManager extends StorageManager<any> {
|
|
9
|
-
prefix: string;
|
|
10
9
|
constructor(prefix?: string);
|
|
11
10
|
private key;
|
|
12
11
|
get<T>(name: string): Promise<T[]>;
|
|
13
12
|
set(name: string, models: any[]): Promise<void>;
|
|
14
13
|
delete(name: string): Promise<void>;
|
|
14
|
+
getParams(): Promise<string[]>;
|
|
15
15
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "live-cache",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "A client-side cache + controller library for stateful resources",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/Subhrajyotimodak/live-cache"
|
|
8
|
+
},
|
|
5
9
|
"main": "dist/index.cjs",
|
|
6
10
|
"module": "dist/index.mjs",
|
|
7
11
|
"types": "dist/index.d.ts",
|