Skip to content

Commit 1dc2413

Browse files
committed
Windows: Minor refactoring
1 parent b43b0a8 commit 1dc2413

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

windows/ReactNativeStaticServer/ReactNativeModule.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,18 @@ void unlock_sem() {
3636
}
3737

3838
void OnSignal(std::string signal, std::string details) {
39-
if (pendingResult) {
40-
if (signal == CRASHED) RNException("Server crashed").reject(*pendingResult);
41-
else pendingResult->Resolve(details);
42-
}
43-
else {
44-
// CAREFUL: sendEvent() depends on server object to get it ID,
45-
// thus MUST BE called before the server instance is dropped below.
46-
mod->sendEvent(signal, details);
47-
}
39+
// BEWARE: .sendEvent() depends on the server object to get its ID,
40+
// thus MUST BE called before the object is dropped below, if it is.
41+
if (!pendingResult) mod->sendEvent(signal, details);
4842

4943
if (signal == CRASHED || signal == TERMINATED) {
5044
delete server;
5145
server = NULL;
5246
}
5347

5448
if (pendingResult) {
49+
if (signal == CRASHED) RNException("Server crashed").reject(*pendingResult);
50+
else pendingResult->Resolve(details);
5551
delete pendingResult;
5652
pendingResult = NULL;
5753
unlock_sem();

0 commit comments

Comments
 (0)