|
7 | 7 |
|
8 | 8 | package com.facebook.react.bridge;
|
9 | 9 |
|
| 10 | +import javax.annotation.Nonnull; |
10 | 11 | import javax.annotation.Nullable;
|
11 | 12 |
|
12 |
| -/** |
| 13 | +/* |
13 | 14 | * Interface that represents a JavaScript Promise which can be passed to the native module as a
|
14 | 15 | * method parameter.
|
15 | 16 | *
|
16 |
| - * Methods annotated with {@link ReactMethod} that use {@link Promise} as type of the last parameter |
| 17 | + * Methods annotated with {@link ReactMethod} that use a {@link Promise} as the last parameter |
17 | 18 | * will be marked as "promise" and will return a promise when invoked from JavaScript.
|
18 | 19 | */
|
19 | 20 | public interface Promise {
|
20 | 21 |
|
21 | 22 | /**
|
22 |
| - * Successfully resolve the Promise. |
| 23 | + * Successfully resolve the Promise with an optional value. |
| 24 | + * |
| 25 | + * @param value Object |
23 | 26 | */
|
24 | 27 | void resolve(@Nullable Object value);
|
25 | 28 |
|
26 | 29 | /**
|
27 |
| - * Report an error which wasn't caused by an exception. |
| 30 | + * Report an error without an exception using a custom code and error message. |
| 31 | + * |
| 32 | + * @param code String |
| 33 | + * @param message String |
28 | 34 | */
|
29 | 35 | void reject(String code, String message);
|
30 | 36 |
|
31 | 37 | /**
|
32 |
| - * Report an exception. |
| 38 | + * Report an exception with a custom code. |
| 39 | + * |
| 40 | + * @param code String |
| 41 | + * @param throwable Throwable |
33 | 42 | */
|
34 |
| - void reject(String code, Throwable e); |
| 43 | + void reject(String code, Throwable throwable); |
35 | 44 |
|
36 | 45 | /**
|
37 |
| - * Report an exception with a custom error message. |
| 46 | + * Report an exception with a custom code and error message. |
| 47 | + * |
| 48 | + * @param code String |
| 49 | + * @param message String |
| 50 | + * @param throwable Throwable |
38 | 51 | */
|
39 |
| - void reject(String code, String message, Throwable e); |
| 52 | + void reject(String code, String message, Throwable throwable); |
| 53 | + |
40 | 54 |
|
41 | 55 | /**
|
42 |
| - * Report an error which wasn't caused by an exception. |
43 |
| - * @deprecated Prefer passing a module-specific error code to JS. |
44 |
| - * Using this method will pass the error code "EUNSPECIFIED". |
| 56 | + * Report an exception, with default error code. |
| 57 | + * Useful in catch-all scenarios where it's unclear why the error occurred. |
| 58 | + * |
| 59 | + * @param throwable Throwable |
45 | 60 | */
|
46 |
| - @Deprecated |
47 |
| - void reject(String message); |
| 61 | + void reject(Throwable throwable); |
| 62 | + |
| 63 | + /* --------------------------- |
| 64 | + * With userInfo WritableMap |
| 65 | + * --------------------------- */ |
48 | 66 |
|
49 | 67 | /**
|
50 |
| - * Report an exception, with default error code. |
| 68 | + * Report an exception, with default error code, with userInfo. |
51 | 69 | * Useful in catch-all scenarios where it's unclear why the error occurred.
|
| 70 | + * |
| 71 | + * @param throwable Throwable |
| 72 | + * @param userInfo WritableMap |
| 73 | + */ |
| 74 | + void reject(Throwable throwable, WritableMap userInfo); |
| 75 | + |
| 76 | + /** |
| 77 | + * Reject with a code and userInfo WritableMap. |
| 78 | + * |
| 79 | + * @param code String |
| 80 | + * @param userInfo WritableMap |
52 | 81 | */
|
53 |
| - void reject(Throwable reason); |
| 82 | + void reject(String code, @Nonnull WritableMap userInfo); |
| 83 | + |
| 84 | + /** |
| 85 | + * Report an exception with a custom code and userInfo. |
| 86 | + * |
| 87 | + * @param code String |
| 88 | + * @param throwable Throwable |
| 89 | + * @param userInfo WritableMap |
| 90 | + */ |
| 91 | + void reject(String code, Throwable throwable, WritableMap userInfo); |
| 92 | + |
| 93 | + /** |
| 94 | + * Report an error with a custom code, error message and userInfo, |
| 95 | + * an error not caused by an exception. |
| 96 | + * |
| 97 | + * @param code String |
| 98 | + * @param message String |
| 99 | + * @param userInfo WritableMap |
| 100 | + */ |
| 101 | + void reject(String code, String message, @Nonnull WritableMap userInfo); |
| 102 | + |
| 103 | + /** |
| 104 | + * Report an exception with a custom code, error message and userInfo. |
| 105 | + * |
| 106 | + * @param code String |
| 107 | + * @param message String |
| 108 | + * @param throwable Throwable |
| 109 | + * @param userInfo WritableMap |
| 110 | + */ |
| 111 | + void reject(String code, String message, Throwable throwable, WritableMap userInfo); |
| 112 | + |
| 113 | + /* ------------ |
| 114 | + * Deprecated |
| 115 | + * ------------ */ |
| 116 | + |
| 117 | + /** |
| 118 | + * Report an error which wasn't caused by an exception. |
| 119 | + * |
| 120 | + * @deprecated Prefer passing a module-specific error code to JS. |
| 121 | + * Using this method will pass the error code "EUNSPECIFIED". |
| 122 | + */ |
| 123 | + @Deprecated |
| 124 | + void reject(String message); |
54 | 125 | }
|
0 commit comments