@arrai-innovations/reactive-helpers 4.2.1 → 4.3.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arrai-innovations/reactive-helpers",
3
- "version": "4.2.1",
3
+ "version": "4.3.0",
4
4
  "description": "VueJS 3 utility composition functions to help manipulate objects and lists.",
5
5
  "main": "index.js",
6
6
  "directories": {
package/use/list.js CHANGED
@@ -6,7 +6,7 @@ import { usePagedListInstance } from "./paginatedListInstance";
6
6
  import { effectScope, reactive, shallowReactive, shallowReadonly, toRef, watch } from "vue";
7
7
 
8
8
  // the big brother of useObject, managing a chain of useList* instances.
9
- export const useList = ({ props, functions, paged = false, passThroughPropertyNames = [] }) => {
9
+ export const useList = ({ props, functions, paged = false, keepOldPages = false, passThroughPropertyNames = [] }) => {
10
10
  const managed = shallowReactive({
11
11
  listInstance: null,
12
12
  listSubscription: null,
@@ -20,6 +20,7 @@ export const useList = ({ props, functions, paged = false, passThroughPropertyNa
20
20
  functions,
21
21
  retrieveArgs: toRef(props, "retrieveArgs"),
22
22
  listArgs: toRef(props, "listArgs"),
23
+ keepOldPages,
23
24
  });
24
25
 
25
26
  const intentPropsWatch = () => {
@@ -1,6 +1,6 @@
1
1
  import { useListInstance } from "./listInstance";
2
2
 
3
- export function usePagedListInstance(useListInstanceArgs) {
3
+ export function usePagedListInstance({ keepOldPages = false, ...useListInstanceArgs }) {
4
4
  const listInstance = useListInstance(useListInstanceArgs);
5
5
 
6
6
  listInstance.state.totalRecords = 0;
@@ -8,8 +8,11 @@ export function usePagedListInstance(useListInstanceArgs) {
8
8
  listInstance.state.perPage = 0;
9
9
 
10
10
  listInstance.pageCallback = (newObjects, { totalRecords, totalPages, perPage }) => {
11
- // display one page at a time, clear the list
12
- listInstance.clearList();
11
+ // with keepOldPages, you are responsible for clearing the list as needed
12
+ if (!keepOldPages) {
13
+ // display one page at a time, clear the list
14
+ listInstance.clearList();
15
+ }
13
16
 
14
17
  listInstance.defaultPageCallback(newObjects);
15
18
  if (totalRecords !== undefined) {