@sankhyalabs/core-docs 5.20.0-dev.54 → 5.20.0-dev.55
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/classes/ServiceUtils.md +67 -0
- package/enumerations/StorageType.md +37 -0
- package/globals.md +2 -0
- package/package.json +1 -1
@@ -0,0 +1,67 @@
|
|
1
|
+
[**@sankhyalabs/core**](../README.md) • **Docs**
|
2
|
+
|
3
|
+
***
|
4
|
+
|
5
|
+
[@sankhyalabs/core](../globals.md) / ServiceUtils
|
6
|
+
|
7
|
+
# Class: ServiceUtils
|
8
|
+
|
9
|
+
## Constructors
|
10
|
+
|
11
|
+
### new ServiceUtils()
|
12
|
+
|
13
|
+
> **new ServiceUtils**(): [`ServiceUtils`](ServiceUtils.md)
|
14
|
+
|
15
|
+
#### Returns
|
16
|
+
|
17
|
+
[`ServiceUtils`](ServiceUtils.md)
|
18
|
+
|
19
|
+
## Methods
|
20
|
+
|
21
|
+
### useCacheWithService()
|
22
|
+
|
23
|
+
> `static` **useCacheWithService**\<`T`\>(`identifier`, `fetchFunction`, `storageType`): `Promise`\<`T`\>
|
24
|
+
|
25
|
+
Auxilia no uso do CacheManager, gerando automaticamente uma chave de cache com base no identificador.
|
26
|
+
|
27
|
+
#### Type parameters
|
28
|
+
|
29
|
+
• **T**
|
30
|
+
|
31
|
+
Tipo do dado a ser retornado.
|
32
|
+
|
33
|
+
#### Parameters
|
34
|
+
|
35
|
+
• **identifier**: `string`
|
36
|
+
|
37
|
+
Identificadores únicos usados para compor a chave de cache.
|
38
|
+
|
39
|
+
• **fetchFunction**
|
40
|
+
|
41
|
+
Função que retorna uma `Promise` com o valor a ser armazenado no cache caso ele não exista ou tenha expirado.
|
42
|
+
|
43
|
+
• **storageType**: [`StorageType`](../enumerations/StorageType.md)= `StorageType.IN_MEMORY_CACHE`
|
44
|
+
|
45
|
+
Tipo de armazenamento: `'sessionStorage'` ou `'localStorage'`. O padrão é `'sessionStorage'`.
|
46
|
+
|
47
|
+
#### Returns
|
48
|
+
|
49
|
+
`Promise`\<`T`\>
|
50
|
+
|
51
|
+
Uma `Promise` com o valor armazenado ou obtido via `fetchFunction`.
|
52
|
+
|
53
|
+
#### Example
|
54
|
+
|
55
|
+
```typescript
|
56
|
+
const actions = await useCacheWithService(
|
57
|
+
`${this.entityName} - ${this.resourceID}`,
|
58
|
+
async () => {
|
59
|
+
return await fetchActionsFromAPI();
|
60
|
+
}
|
61
|
+
);
|
62
|
+
console.log(actions);
|
63
|
+
```
|
64
|
+
|
65
|
+
#### Source
|
66
|
+
|
67
|
+
src/utils/ServiceUtils.ts:28
|
@@ -0,0 +1,37 @@
|
|
1
|
+
[**@sankhyalabs/core**](../README.md) • **Docs**
|
2
|
+
|
3
|
+
***
|
4
|
+
|
5
|
+
[@sankhyalabs/core](../globals.md) / StorageType
|
6
|
+
|
7
|
+
# Enumeration: StorageType
|
8
|
+
|
9
|
+
## Enumeration Members
|
10
|
+
|
11
|
+
### IN\_MEMORY\_CACHE
|
12
|
+
|
13
|
+
> **IN\_MEMORY\_CACHE**: `"inMemoryCache"`
|
14
|
+
|
15
|
+
#### Source
|
16
|
+
|
17
|
+
src/utils/CacheManager/interfaces/index.ts:2
|
18
|
+
|
19
|
+
***
|
20
|
+
|
21
|
+
### LOCAL\_STORAGE
|
22
|
+
|
23
|
+
> **LOCAL\_STORAGE**: `"localStorage"`
|
24
|
+
|
25
|
+
#### Source
|
26
|
+
|
27
|
+
src/utils/CacheManager/interfaces/index.ts:4
|
28
|
+
|
29
|
+
***
|
30
|
+
|
31
|
+
### SESSION\_STORAGE
|
32
|
+
|
33
|
+
> **SESSION\_STORAGE**: `"sessionStorage"`
|
34
|
+
|
35
|
+
#### Source
|
36
|
+
|
37
|
+
src/utils/CacheManager/interfaces/index.ts:3
|
package/globals.md
CHANGED
@@ -17,6 +17,7 @@
|
|
17
17
|
- [OverflowDirection](enumerations/OverflowDirection.md)
|
18
18
|
- [SelectionMode](enumerations/SelectionMode.md)
|
19
19
|
- [SortMode](enumerations/SortMode.md)
|
20
|
+
- [StorageType](enumerations/StorageType.md)
|
20
21
|
- [UserInterface](enumerations/UserInterface.md)
|
21
22
|
|
22
23
|
## Classes
|
@@ -50,6 +51,7 @@
|
|
50
51
|
- [SearchUtils](classes/SearchUtils.md)
|
51
52
|
- [SelectionInfo](classes/SelectionInfo.md)
|
52
53
|
- [ServiceCanceledException](classes/ServiceCanceledException.md)
|
54
|
+
- [ServiceUtils](classes/ServiceUtils.md)
|
53
55
|
- [SkwHttpProvider](classes/SkwHttpProvider.md)
|
54
56
|
- [StringUtils](classes/StringUtils.md)
|
55
57
|
- [TimeFormatter](classes/TimeFormatter.md)
|