ballerina-core 1.0.176 → 1.0.178

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
@@ -2,7 +2,7 @@
2
2
  "name": "ballerina-core",
3
3
  "author": "Dr. Giuseppe Maggiore",
4
4
  "private": false,
5
- "version": "1.0.176",
5
+ "version": "1.0.178",
6
6
  "main": "main.ts",
7
7
  "scripts": {
8
8
  "prettier": "prettier --write ."
@@ -285,7 +285,7 @@ export const oneTableLoaderRunner = <
285
285
  Co<CustomPresentationContext, ExtraContext>().Template<
286
286
  OneAbstractRendererForeignMutationsExpected<Flags>
287
287
  >(
288
- ValueInfiniteStreamLoader.embed(
288
+ ValueInfiniteStreamLoader().embed(
289
289
  (_) => _.customFormState.stream,
290
290
  OneAbstractRendererState.Updaters.Core.customFormState.children.stream,
291
291
  ),
@@ -65,6 +65,7 @@ export const DispatchFormRunnerTemplate = <
65
65
  context={{
66
66
  ...props.context.formState,
67
67
  value: entity.value.value,
68
+ disabled: false,
68
69
  bindings,
69
70
  extraContext: props.context.extraContext,
70
71
  remoteEntityVersionIdentifier:
@@ -1,49 +1,78 @@
1
+ import { Unit } from "../../../main";
1
2
  import { AsyncState } from "../../async/state";
3
+ import { Coroutine } from "../../coroutines/state";
2
4
  import { replaceWith } from "../../fun/domains/updater/domains/replaceWith/state";
3
- import { ValueInfiniteStreamState, ValueStreamPosition } from "../state";
5
+ import {
6
+ ValueInfiniteStreamState,
7
+ ValueInfiniteStreamWritableState,
8
+ ValueStreamPosition,
9
+ } from "../state";
4
10
  import { ValueStreamCo } from "./builder";
5
11
 
6
- const Co = ValueStreamCo();
7
- const updaters = ValueInfiniteStreamState.Updaters;
12
+ export const ValueInfiniteStreamLoader = (maxRetries = 3) => {
13
+ const Co = ValueStreamCo();
14
+ const updaters = ValueInfiniteStreamState.Updaters;
8
15
 
9
- export const ValueInfiniteStreamLoader = Co.Seq([
10
- Co.SetState(
11
- updaters.Core.loadingMore(replaceWith(AsyncState.Default.loading())),
12
- ),
13
- Co.While(
14
- ([current]) => current.loadingMore.kind != "loaded",
16
+ const attemptLoad = (
17
+ retryCount = 0,
18
+ ): Coroutine<
19
+ ValueInfiniteStreamWritableState,
20
+ ValueInfiniteStreamWritableState,
21
+ Unit
22
+ > =>
15
23
  Co.GetState().then((current) =>
16
- Co.Await(
17
- () => current.getChunk([current.position]),
18
- () => "error" as const,
19
- ).then((apiResult) => {
20
- return apiResult.kind == "l"
21
- ? Co.SetState(
22
- updaters.Core.loadingMore(
23
- replaceWith(AsyncState.Default.loaded({})),
24
- )
25
- .then(
26
- updaters.Coroutine.addLoadedChunk(
27
- current.position.chunkIndex,
28
- apiResult.value,
29
- ).then(
30
- updaters.Core.position(
31
- ValueStreamPosition.Updaters.Core.shouldLoad(
32
- replaceWith<ValueStreamPosition["shouldLoad"]>(false),
24
+ current.loadingMore.kind === "loaded"
25
+ ? Co.Return(true)
26
+ : Co.Await(
27
+ () => current.getChunk([current.position]),
28
+ () => "error" as const,
29
+ ).then((apiResult) => {
30
+ return apiResult.kind == "l"
31
+ ? Co.SetState(
32
+ updaters.Core.loadingMore(
33
+ replaceWith(AsyncState.Default.loaded({})),
34
+ )
35
+ .then(
36
+ updaters.Coroutine.addLoadedChunk(
37
+ current.position.chunkIndex,
38
+ apiResult.value,
39
+ ).then(
40
+ updaters.Core.position(
41
+ ValueStreamPosition.Updaters.Core.shouldLoad(
42
+ replaceWith<ValueStreamPosition["shouldLoad"]>(
43
+ false,
44
+ ),
45
+ ),
46
+ ),
47
+ ),
48
+ )
49
+ .then(
50
+ updaters.Core.position(
51
+ ValueStreamPosition.Updaters.Core.nextStart(
52
+ replaceWith(apiResult.value.to + 1),
53
+ ),
33
54
  ),
34
55
  ),
35
- ),
36
56
  )
37
- .then(
38
- updaters.Core.position(
39
- ValueStreamPosition.Updaters.Core.nextStart(
40
- replaceWith(apiResult.value.to + 1),
41
- ),
42
- ),
43
- ),
44
- )
45
- : Co.Wait(500);
46
- }),
57
+ : retryCount < maxRetries
58
+ ? Co.Wait(500).then(() => attemptLoad(retryCount + 1))
59
+ : Co.Return(false);
60
+ }),
61
+ );
62
+
63
+ return Co.Seq([
64
+ Co.SetState(
65
+ updaters.Core.loadingMore(replaceWith(AsyncState.Default.loading())),
66
+ ),
67
+ attemptLoad(),
68
+ Co.GetState().then((current) =>
69
+ current.loadingMore.kind !== "loaded"
70
+ ? Co.SetState(
71
+ updaters.Core.loadingMore(
72
+ replaceWith(AsyncState.Default.error("max retries reached")),
73
+ ),
74
+ )
75
+ : Co.Wait(0),
47
76
  ),
48
- ),
49
- ]);
77
+ ]);
78
+ };
@@ -3,7 +3,7 @@ import { ValueStreamCo } from "./builder";
3
3
  import { ValueInfiniteStreamLoader } from "./infiniteLoader";
4
4
 
5
5
  export const ValueStreamDataLoader = <foreignMutations>() =>
6
- ValueStreamCo().Template<foreignMutations>(ValueInfiniteStreamLoader, {
6
+ ValueStreamCo().Template<foreignMutations>(ValueInfiniteStreamLoader(), {
7
7
  runFilter: (props) =>
8
8
  ValueInfiniteStreamState.Operations.shouldCoroutineRun(props.context),
9
9
  });