react-native-nitro-modules 0.26.0 → 0.26.1
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/cpp/core/Promise.hpp +17 -0
- package/cpp/utils/NitroDefines.hpp +1 -1
- package/package.json +1 -1
package/cpp/core/Promise.hpp
CHANGED
|
@@ -106,6 +106,7 @@ public:
|
|
|
106
106
|
for (const auto& onResolved : _onResolvedListeners) {
|
|
107
107
|
onResolved(std::get<TResult>(_state));
|
|
108
108
|
}
|
|
109
|
+
didFinish();
|
|
109
110
|
}
|
|
110
111
|
void resolve(const TResult& result) {
|
|
111
112
|
std::unique_lock lock(_mutex);
|
|
@@ -116,6 +117,7 @@ public:
|
|
|
116
117
|
for (const auto& onResolved : _onResolvedListeners) {
|
|
117
118
|
onResolved(std::get<TResult>(_state));
|
|
118
119
|
}
|
|
120
|
+
didFinish();
|
|
119
121
|
}
|
|
120
122
|
/**
|
|
121
123
|
* Rejects this Promise with the given error, and calls any pending listeners.
|
|
@@ -134,6 +136,7 @@ public:
|
|
|
134
136
|
for (const auto& onRejected : _onRejectedListeners) {
|
|
135
137
|
onRejected(exception);
|
|
136
138
|
}
|
|
139
|
+
didFinish();
|
|
137
140
|
}
|
|
138
141
|
|
|
139
142
|
public:
|
|
@@ -245,6 +248,12 @@ public:
|
|
|
245
248
|
return std::holds_alternative<std::monostate>(_state);
|
|
246
249
|
}
|
|
247
250
|
|
|
251
|
+
private:
|
|
252
|
+
void didFinish() noexcept {
|
|
253
|
+
_onResolvedListeners.clear();
|
|
254
|
+
_onRejectedListeners.clear();
|
|
255
|
+
}
|
|
256
|
+
|
|
248
257
|
private:
|
|
249
258
|
std::variant<std::monostate, TResult, std::exception_ptr> _state;
|
|
250
259
|
std::vector<OnResolvedFunc> _onResolvedListeners;
|
|
@@ -319,6 +328,7 @@ public:
|
|
|
319
328
|
for (const auto& onResolved : _onResolvedListeners) {
|
|
320
329
|
onResolved();
|
|
321
330
|
}
|
|
331
|
+
didFinish();
|
|
322
332
|
}
|
|
323
333
|
void reject(const std::exception_ptr& exception) {
|
|
324
334
|
if (exception == nullptr) [[unlikely]] {
|
|
@@ -333,6 +343,7 @@ public:
|
|
|
333
343
|
for (const auto& onRejected : _onRejectedListeners) {
|
|
334
344
|
onRejected(exception);
|
|
335
345
|
}
|
|
346
|
+
didFinish();
|
|
336
347
|
}
|
|
337
348
|
|
|
338
349
|
public:
|
|
@@ -401,6 +412,12 @@ public:
|
|
|
401
412
|
return !isResolved() && !isRejected();
|
|
402
413
|
}
|
|
403
414
|
|
|
415
|
+
private:
|
|
416
|
+
void didFinish() noexcept {
|
|
417
|
+
_onResolvedListeners.clear();
|
|
418
|
+
_onRejectedListeners.clear();
|
|
419
|
+
}
|
|
420
|
+
|
|
404
421
|
private:
|
|
405
422
|
std::mutex _mutex;
|
|
406
423
|
bool _isResolved = false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-modules",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.1",
|
|
4
4
|
"description": "Insanely fast native C++, Swift or Kotlin modules with a statically compiled binding layer to JSI.",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|