@sankhyalabs/core 5.20.0-dev.52 → 5.20.0-dev.54
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/.docs/classes/Change.md +11 -11
- package/.docs/classes/DataUnit.md +32 -24
- package/.docs/classes/SelectionInfo.md +12 -12
- package/.docs/enumerations/ChangeOperation.md +4 -4
- package/.docs/enumerations/SelectionMode.md +2 -2
- package/.docs/interfaces/DUActionInterceptor.md +1 -1
- package/.docs/interfaces/PageRequest.md +3 -3
- package/.docs/interfaces/PaginationInfo.md +13 -0
- package/.docs/interfaces/QuickFilter.md +3 -3
- package/.docs/interfaces/Record.md +4 -4
- package/.docs/interfaces/SavedRecord.md +5 -5
- package/.docs/interfaces/WaitingChange.md +3 -3
- package/.docs/type-aliases/DataUnitEventOptions.md +1 -1
- package/bun.lockb +0 -0
- package/dist/dataunit/DataUnit.d.ts +4 -4
- package/dist/dataunit/DataUnit.js +25 -12
- package/dist/dataunit/DataUnit.js.map +1 -1
- package/dist/dataunit/loading/PaginationInfo.d.ts +4 -0
- package/package.json +1 -1
- package/reports/test-report.xml +99 -99
- package/src/dataunit/DataUnit.ts +25 -13
- package/src/dataunit/loading/PaginationInfo.ts +5 -0
package/src/dataunit/DataUnit.ts
CHANGED
|
@@ -40,7 +40,7 @@ export default class DataUnit {
|
|
|
40
40
|
|
|
41
41
|
private _uuid: string;
|
|
42
42
|
private _name: string;
|
|
43
|
-
private _observers:
|
|
43
|
+
private _observers: Map<string, (action: DataUnitAction, options?: DataUnitEventOptions) => void>;
|
|
44
44
|
private _sortingProvider?: SortingProvider;
|
|
45
45
|
private _filterProviders: Map<string, FilterProvider>;
|
|
46
46
|
private _stateManager: StateManager;
|
|
@@ -81,7 +81,7 @@ export default class DataUnit {
|
|
|
81
81
|
SnapshotReducer
|
|
82
82
|
]
|
|
83
83
|
);
|
|
84
|
-
this._observers =
|
|
84
|
+
this._observers = new Map();
|
|
85
85
|
this._filterProviders = new Map<string, FilterProvider>();
|
|
86
86
|
this._sortingProvider = undefined;
|
|
87
87
|
this._defaultSorting = [];
|
|
@@ -119,7 +119,7 @@ export default class DataUnit {
|
|
|
119
119
|
public releaseCallbacks(){
|
|
120
120
|
if(!this._allowReleaseCallbacks) return;
|
|
121
121
|
|
|
122
|
-
this._observers =
|
|
122
|
+
this._observers = new Map();
|
|
123
123
|
this._filterProviders = new Map<string, FilterProvider>();
|
|
124
124
|
this._sortingProvider = undefined;
|
|
125
125
|
this._interceptors = new Map();
|
|
@@ -1579,10 +1579,7 @@ export default class DataUnit {
|
|
|
1579
1579
|
this._stateManager.process(action);
|
|
1580
1580
|
this?._parentDataUnit?.dispatchAction(Action.CHILD_CHANGED, { srcAction: action, srcDataUnit: this });
|
|
1581
1581
|
this._observers.forEach(f => {
|
|
1582
|
-
|
|
1583
|
-
if some observer throws exceptions,
|
|
1584
|
-
should be continued
|
|
1585
|
-
*/
|
|
1582
|
+
//if some observer throws exceptions, should be continued
|
|
1586
1583
|
try {
|
|
1587
1584
|
f(action, options);
|
|
1588
1585
|
} catch (e) {
|
|
@@ -1621,10 +1618,17 @@ export default class DataUnit {
|
|
|
1621
1618
|
* Ela vai ser chamada sempre que uma ação for despachada (dispatchAction()).
|
|
1622
1619
|
*
|
|
1623
1620
|
* @param observer - Função que recebe como parâmetro as ações que serão monitoradas.
|
|
1624
|
-
*
|
|
1621
|
+
* @param uuid - Identificador do observer. Quando não informado, será gerado um identificador aleatório.
|
|
1625
1622
|
*/
|
|
1626
|
-
public subscribe(observer: (action: DataUnitAction, options?:DataUnitEventOptions) => void | Promise<void
|
|
1627
|
-
|
|
1623
|
+
public subscribe(observer: (action: DataUnitAction, options?: DataUnitEventOptions) => void | Promise<void>, uuid?: string): string {
|
|
1624
|
+
if (uuid) {
|
|
1625
|
+
this._observers.set(uuid, observer);
|
|
1626
|
+
} else {
|
|
1627
|
+
uuid = StringUtils.generateUUID();
|
|
1628
|
+
this._observers.set(uuid, observer);
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
return uuid;
|
|
1628
1632
|
}
|
|
1629
1633
|
|
|
1630
1634
|
/**
|
|
@@ -1632,10 +1636,18 @@ export default class DataUnit {
|
|
|
1632
1636
|
* Remove um observer existente.
|
|
1633
1637
|
*
|
|
1634
1638
|
* @param observer - Observer que se deseja remover.
|
|
1635
|
-
*
|
|
1639
|
+
* @param uuid - Identificador do observer. Quando não informado o delete removera com base no equals do observer.
|
|
1636
1640
|
*/
|
|
1637
|
-
public unsubscribe(observer: Function) {
|
|
1638
|
-
|
|
1641
|
+
public unsubscribe(observer: Function, uuid?: string) {
|
|
1642
|
+
if (uuid) {
|
|
1643
|
+
this._observers.delete(uuid);
|
|
1644
|
+
} else {
|
|
1645
|
+
this._observers.forEach((valor, chave) => {
|
|
1646
|
+
if (valor == observer) {
|
|
1647
|
+
this._observers.delete(chave);
|
|
1648
|
+
}
|
|
1649
|
+
});
|
|
1650
|
+
}
|
|
1639
1651
|
}
|
|
1640
1652
|
|
|
1641
1653
|
/**
|
|
@@ -18,4 +18,9 @@ export interface PaginationInfo {
|
|
|
18
18
|
|
|
19
19
|
/** Se ainda existem mais registros */
|
|
20
20
|
hasMore: boolean;
|
|
21
|
+
|
|
22
|
+
/** Informa se o carregamento de dados em background está sendo executado
|
|
23
|
+
* Caso o dataunit não tenha carga paralela o valor será indefinido
|
|
24
|
+
*/
|
|
25
|
+
loadingInProgress?: boolean;
|
|
21
26
|
}
|