exupery-core-async 0.1.12 → 0.1.14

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.
@@ -11,8 +11,8 @@ export interface Safe_Query_Result<T> {
11
11
  * @param handle_value callback that transforms the actual value into a new Async_Value
12
12
  */
13
13
  then<NT>(handle_value: ($: T) => Safe_Query_Result<NT>): Safe_Query_Result<NT>;
14
- execute_safe_command(handle_value: ($: T) => Safe_Command_Result): Safe_Command_Result;
15
- execute_unsafe_command<E>(handle_value: ($: T) => Unsafe_Command_Result<E>): Unsafe_Command_Result<E>;
14
+ process_safe(handle_value: ($: T) => Safe_Command_Result): Safe_Command_Result;
15
+ process_unsafe<E>(handle_value: ($: T) => Unsafe_Command_Result<E>): Unsafe_Command_Result<E>;
16
16
  /**
17
17
  * This method is only to be used by resources
18
18
  */
@@ -1,3 +1,4 @@
1
+ import { Safe_Command_Result } from "./Safe_Command_Result";
1
2
  import { Safe_Query_Result } from "./Safe_Query_Result";
2
3
  import { Unsafe_Command_Result } from "./Unsafe_Command_Result";
3
4
  export interface Unsafe_Query_Result<T, E> {
@@ -5,6 +6,19 @@ export interface Unsafe_Query_Result<T, E> {
5
6
  map_exception<NE>(handle_exception: ($: E) => NE): Unsafe_Query_Result<T, NE>;
6
7
  then<NT>(handle_value: ($: T) => Unsafe_Query_Result<NT, E>): Unsafe_Query_Result<NT, E>;
7
8
  catch(handle_exception: ($: E) => T): Safe_Query_Result<T>;
8
- execute_unsafe_command(handle_value: ($: T) => Unsafe_Command_Result<E>): Unsafe_Command_Result<E>;
9
+ /**
10
+ * processes the queried data by executing a command.
11
+ *
12
+ * if the result on which this method is called is in an exception state, the command will not be executed.
13
+ * instead, the 2 other handlers will be called.
14
+ * first, the exception handler will be called, to report the exception.
15
+ * secondly, the exception will be mapped into a new exception value that has the same type as the command's exception type.
16
+ *
17
+ * @param handle_value the handler that will be called to process the queried data, if no exception has occurred
18
+ * @param handle_exception the handler that will process an exception if the query is in an exception state to allow reporting the exception
19
+ * @param map_exception the handler that will map the exception of the query into a new exception value of the command's exception type
20
+ *
21
+ */
22
+ process<NE>(handle_value: ($: T) => Unsafe_Command_Result<NE>, handle_exception: ($: E) => Safe_Command_Result, map_exception: ($: E) => NE): Unsafe_Command_Result<NE>;
9
23
  __start(on_value: ($: T) => void, on_exception: ($: E) => void): void;
10
24
  }
@@ -25,7 +25,7 @@ class Safe_Query_Result_Class {
25
25
  }
26
26
  });
27
27
  }
28
- execute_safe_command(handle_value) {
28
+ process_safe(handle_value) {
29
29
  return (0, execute_safe_command_1.__execute_safe_command)({
30
30
  'execute': (on_success) => {
31
31
  this.executer.execute((value) => {
@@ -34,7 +34,7 @@ class Safe_Query_Result_Class {
34
34
  }
35
35
  });
36
36
  }
37
- execute_unsafe_command(handle_value) {
37
+ process_unsafe(handle_value) {
38
38
  return (0, execute_unsafe_command_1.__execute_unsafe_command)({
39
39
  'execute': (on_success, on_exception) => {
40
40
  this.executer.execute((value) => {
@@ -43,12 +43,14 @@ class Unsafe_Query_Result_Class {
43
43
  }
44
44
  });
45
45
  }
46
- execute_unsafe_command(handle_value) {
46
+ process(handle_value, handle_exception, map_exception) {
47
47
  return (0, execute_unsafe_command_1.__execute_unsafe_command)({
48
48
  'execute': (on_success, on_exception) => {
49
49
  this.executer.execute((value) => {
50
50
  handle_value(value).__start(on_success, on_exception);
51
- }, on_exception);
51
+ }, (exception) => {
52
+ handle_exception(exception).__start(() => on_exception(map_exception(exception)));
53
+ });
52
54
  }
53
55
  });
54
56
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exupery-core-async",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "license": "Apache-2.0",
5
5
  "author": "Corno",
6
6
  "description": "async types for Exupery",