exupery-core-async 0.1.15 → 0.1.17
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.
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as _et from 'exupery-core-types';
|
|
2
2
|
import { Safe_Command_Result } from "./Safe_Command_Result";
|
|
3
3
|
export interface Unsafe_Command_Result<E> {
|
|
4
|
-
map_exception<NE>(handle_exception: ($: E) => NE): Unsafe_Command_Result<NE>;
|
|
5
4
|
/**
|
|
6
5
|
*
|
|
7
6
|
* executes a command when an exception has occurred,
|
|
@@ -14,9 +13,10 @@ export interface Unsafe_Command_Result<E> {
|
|
|
14
13
|
* note that this is different from `catch`,
|
|
15
14
|
* which would switch to the safe context
|
|
16
15
|
*/
|
|
17
|
-
|
|
16
|
+
process_exception<NE>(handle: ($: E) => Safe_Command_Result, map: ($: E) => NE): Unsafe_Command_Result<NE>;
|
|
18
17
|
catch(handle_exception: ($: E) => Safe_Command_Result): Safe_Command_Result;
|
|
19
18
|
then(handle: () => Unsafe_Command_Result<E>): Unsafe_Command_Result<E>;
|
|
20
19
|
then_dictionary<E2>($: _et.Dictionary<Unsafe_Command_Result<E2>>, aggregate_exceptions: ($: _et.Dictionary<E2>) => E): Unsafe_Command_Result<E>;
|
|
20
|
+
then_multiple<E2>($: _et.Array<Unsafe_Command_Result<E2>>, aggregate_exceptions: ($: _et.Array<E2>) => E): Unsafe_Command_Result<E>;
|
|
21
21
|
__start(on_success: () => void, on_exception: ($: E) => void): void;
|
|
22
22
|
}
|
|
@@ -5,7 +5,7 @@ export interface Unsafe_Query_Result<T, E> {
|
|
|
5
5
|
map<NT>(handle_value: ($: T) => NT): Unsafe_Query_Result<NT, E>;
|
|
6
6
|
map_exception<NE>(handle_exception: ($: E) => NE): Unsafe_Query_Result<T, NE>;
|
|
7
7
|
then<NT>(handle_value: ($: T) => Unsafe_Query_Result<NT, E>): Unsafe_Query_Result<NT, E>;
|
|
8
|
-
catch(handle_exception: ($: E) => T): Safe_Query_Result<T>;
|
|
8
|
+
catch(handle_exception: ($: E) => Safe_Query_Result<T>): Safe_Query_Result<T>;
|
|
9
9
|
/**
|
|
10
10
|
* processes the queried data by executing a command.
|
|
11
11
|
*
|
|
@@ -31,11 +31,11 @@ class Unsafe_Command_Result_Class {
|
|
|
31
31
|
constructor(executer) {
|
|
32
32
|
this.executer = executer;
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
process_exception(handle, map) {
|
|
35
35
|
return new Unsafe_Command_Result_Class({
|
|
36
36
|
'execute': (new_on_success, new_on_exception) => {
|
|
37
37
|
this.executer.execute(new_on_success, ($) => {
|
|
38
|
-
|
|
38
|
+
handle($).__start(() => new_on_exception(map($)));
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
});
|
|
@@ -92,6 +92,31 @@ class Unsafe_Command_Result_Class {
|
|
|
92
92
|
}
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
|
+
then_multiple($, aggregate_exceptions) {
|
|
96
|
+
let exceptions = [];
|
|
97
|
+
return __execute_unsafe_command({
|
|
98
|
+
'execute': (on_success, on_exception) => {
|
|
99
|
+
(0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((monitor) => {
|
|
100
|
+
$.map(($) => {
|
|
101
|
+
monitor['report process started']();
|
|
102
|
+
$.__start(() => {
|
|
103
|
+
monitor['report process finished']();
|
|
104
|
+
}, (e) => {
|
|
105
|
+
exceptions.push(e);
|
|
106
|
+
monitor['report process finished']();
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
}, () => {
|
|
110
|
+
if (exceptions.length === 0) {
|
|
111
|
+
on_success();
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
on_exception(aggregate_exceptions(_ei.array_literal(exceptions)));
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
95
120
|
__start(on_success, on_exception) {
|
|
96
121
|
this.executer.execute(on_success, on_exception);
|
|
97
122
|
}
|
package/dist/run_unsafe_query.js
CHANGED