Skip to content

Commit a493ffb

Browse files
push result
1 parent dda8f59 commit a493ffb

File tree

1 file changed

+6
-11
lines changed
  • packages/sources/walkerjs/src/lib

1 file changed

+6
-11
lines changed

packages/sources/walkerjs/src/lib/push.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { handleCommand } from './handle';
44
import {
55
Const,
66
assign,
7+
createPushResult,
78
isArguments,
89
isArray,
910
isCommand,
@@ -26,12 +27,7 @@ export function createPush(instance: SourceWalkerjs.Instance): Elb.Fn {
2627
nested: WalkerOS.Entities = [],
2728
custom: WalkerOS.Properties = {},
2829
) => {
29-
let result: Elb.PushResult = {
30-
status: { ok: false },
31-
successful: [],
32-
queued: [],
33-
failed: [],
34-
};
30+
let result: Elb.PushResult;
3531

3632
return await tryCatchAsync(
3733
async (
@@ -54,20 +50,19 @@ export function createPush(instance: SourceWalkerjs.Instance): Elb.Fn {
5450

5551
if (command) {
5652
// Command event
57-
await handleCommand(instance, command, pushData, options);
53+
result = await handleCommand(instance, command, pushData, options);
5854
} else if (event) {
5955
// Regular event
60-
await pushToDestinations(instance, event);
56+
result = await pushToDestinations(instance, event);
6157
}
6258

63-
return assign({ status: { ok: true } }, result);
59+
return createPushResult(result);
6460
},
6561
(error) => {
6662
// Call custom error handling
6763
if (instance.config.onError) instance.config.onError(error, instance);
6864

69-
result.status.error = String(error);
70-
return result;
65+
return createPushResult({ ok: false });
7166
},
7267
)(nameOrEvent, pushData, options, pushContext, nested, custom);
7368
};

0 commit comments

Comments
 (0)