@applicaster/zapp-react-native-utils 13.0.0-alpha.1855742455 → 13.0.0-alpha.1918049654

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.
@@ -165,7 +165,10 @@ const prepareDefaultActions = (actionExecutor) => {
165
165
 
166
166
  actionExecutor.registerAction(
167
167
  "localStorageToggleFlag",
168
- async (action: ActionType, context?: Record<string, any>): Promise<ActionResult> => {
168
+ async (
169
+ action: ActionType,
170
+ context?: Record<string, any>
171
+ ): Promise<ActionResult> => {
169
172
  const keyNamespace = action.options?.key;
170
173
  const tag = context?.entry?.extensions?.tag;
171
174
 
@@ -0,0 +1,37 @@
1
+ import { TestScheduler } from "rxjs/testing";
2
+
3
+ import { withTimeout$ } from "..";
4
+
5
+ describe("withTimeout$", () => {
6
+ let testScheduler: TestScheduler;
7
+
8
+ beforeEach(() => {
9
+ testScheduler = new TestScheduler((actual, expected) => {
10
+ expect(actual).toEqual(expected);
11
+ });
12
+ });
13
+
14
+ it("should emit undefined after the specified timeout", () => {
15
+ testScheduler.run(({ expectObservable }) => {
16
+ const timeout = 1000;
17
+ const expectedMarble = "1s (a|)";
18
+ const expectedValues = { a: undefined };
19
+
20
+ const result$ = withTimeout$(timeout);
21
+
22
+ expectObservable(result$).toBe(expectedMarble, expectedValues);
23
+ });
24
+ });
25
+
26
+ it("should complete after emitting undefined", () => {
27
+ testScheduler.run(({ expectObservable }) => {
28
+ const timeout = 500;
29
+ const expectedMarble = "500ms (a|)";
30
+ const expectedValues = { a: undefined };
31
+
32
+ const result$ = withTimeout$(timeout);
33
+
34
+ expectObservable(result$).toBe(expectedMarble, expectedValues);
35
+ });
36
+ });
37
+ });
@@ -1,4 +1,4 @@
1
- export { withTimeout } from "./withTimeout";
1
+ export { withTimeout, withTimeout$ } from "./withTimeout";
2
2
 
3
3
  export { onIdle } from "./onIdle";
4
4
 
@@ -1,7 +1,20 @@
1
- export const withTimeout = (timeout: number) => {
2
- return new Promise((resolve) => {
1
+ import { of, Observable } from "rxjs";
2
+ import { delay } from "rxjs/operators";
3
+
4
+ export const withTimeout = (timeout: number): Promise<void> => {
5
+ return new Promise<void>((resolve) => {
3
6
  setTimeout(() => {
4
7
  resolve(undefined);
5
8
  }, timeout);
6
9
  });
7
10
  };
11
+
12
+ /**
13
+ * Creates an observable that emits a single value after a specified timeout.
14
+ *
15
+ * @param timeout - The delay duration in milliseconds before emitting the value.
16
+ * @returns An observable that emits `undefined` after the specified timeout.
17
+ */
18
+ export const withTimeout$ = (timeout: number): Observable<void> => {
19
+ return of(undefined).pipe(delay(timeout));
20
+ };
@@ -5,6 +5,7 @@ exports[`getNavigationProps returns the props otherwise 1`] = `
5
5
  "assets": {
6
6
  "appLogo": "appLogo.png",
7
7
  },
8
+ "data": undefined,
8
9
  "home": false,
9
10
  "nav_items": [
10
11
  {
@@ -111,6 +111,7 @@ export function getNavigationProps({
111
111
  assets: ZappNavBarAssets;
112
112
  rules: ZappNavBarRules;
113
113
  nav_items: NavBarItem[];
114
+ data: MenuItemDataProperties;
114
115
  } | null {
115
116
  const { activeRiver } = navigator;
116
117
  const { navigations, id: selected, home } = activeRiver; // use useRiver hook instead
@@ -124,7 +125,7 @@ export function getNavigationProps({
124
125
  return null;
125
126
  }
126
127
 
127
- const { styles, assets, nav_items, rules } = navigation;
128
+ const { styles, assets, nav_items, rules, data } = navigation;
128
129
 
129
130
  return {
130
131
  selected,
@@ -134,6 +135,7 @@ export function getNavigationProps({
134
135
  assets: assets as ZappNavBarAssets,
135
136
  nav_items: nav_items as any as NavBarItem[],
136
137
  rules: rules as any as ZappNavBarRules,
138
+ data: data as MenuItemDataProperties,
137
139
  };
138
140
  }
139
141
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "13.0.0-alpha.1855742455",
3
+ "version": "13.0.0-alpha.1918049654",
4
4
  "description": "Applicaster Zapp React Native utilities package",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "homepage": "https://github.com/applicaster/quickbrick#readme",
30
30
  "dependencies": {
31
- "@applicaster/applicaster-types": "13.0.0-alpha.1855742455",
31
+ "@applicaster/applicaster-types": "13.0.0-alpha.1918049654",
32
32
  "buffer": "^5.2.1",
33
33
  "camelize": "^1.0.0",
34
34
  "create-react-context": "^0.2.3",
@@ -20,6 +20,7 @@ type Props = {
20
20
  silentRefresh?: boolean;
21
21
  method?: "get" | "post";
22
22
  bodyParams?: Record<string, unknown>;
23
+ skipLoading?: boolean;
23
24
  };
24
25
  };
25
26
 
@@ -93,7 +94,7 @@ export const useFeedLoader = ({
93
94
  if (
94
95
  shouldDispatchData(callableFeedUrl, currentFeed, pipesOptions.clearCache)
95
96
  ) {
96
- if (callableFeedUrl) {
97
+ if (callableFeedUrl && !pipesOptions.skipLoading) {
97
98
  dispatch(
98
99
  loadPipesData(callableFeedUrl, {
99
100
  ...pipesOptions,
@@ -101,26 +102,33 @@ export const useFeedLoader = ({
101
102
  riverId,
102
103
  })
103
104
  );
104
- } else {
105
+ } else if (!callableFeedUrl) {
105
106
  logger.info({
106
107
  message:
107
108
  "Feed is not defined or not inflated, skipping loading. \nMake sure you have correct feedUrl and mapping.",
108
109
  jsOnly: true,
109
110
  });
111
+ } else {
112
+ logger.info({
113
+ message:
114
+ "Loading skipped as per pipesOptions.skipLoading configuration.",
115
+ data: { url: callableFeedUrl },
116
+ jsOnly: true,
117
+ });
110
118
  }
111
119
  } else {
112
120
  logger.info({
113
121
  message:
114
- "Feed already exist, skipping loading. \nCall reloadData() if you want to refresh data.",
122
+ "Feed already exists, skipping loading. \nCall reloadData() if you want to refresh data.",
115
123
  data: { url: callableFeedUrl },
116
124
  jsOnly: true,
117
125
  });
118
126
  }
119
127
  }, []);
120
128
 
121
- // Reload feed when feedUrl changes
129
+ // Reload feed when feedUrl changes, unless skipLoading is true
122
130
  useEffect(() => {
123
- if (!isInitialRender && callableFeedUrl) {
131
+ if (!isInitialRender && callableFeedUrl && !pipesOptions.skipLoading) {
124
132
  dispatch(loadPipesData(callableFeedUrl, { ...pipesOptions, riverId }));
125
133
  }
126
134
  }, [callableFeedUrl]);
@@ -156,7 +164,6 @@ export const useFeedLoader = ({
156
164
  currentFeed?.data,
157
165
  currentFeed?.error,
158
166
  currentFeed?.loading,
159
-
160
167
  reloadData,
161
168
  loadNext,
162
169
  ]);