Skip to content

Commit 266bbee

Browse files
committed
Add an option to runScript without waiting for result
To be used for calling LiveSync
1 parent 509cd53 commit 266bbee

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

test-app/app/src/debug/java/com/tns/NativeScriptSyncServiceSocketImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public void run() {
165165

166166
validateData();
167167
if(runtime != null && doRefreshInt == DO_REFRESH_VALUE) {
168-
runtime.runScript(new File(NativeScriptSyncServiceSocketImpl.this.context.getFilesDir(), "internal/livesync.js"));
168+
runtime.runScript(new File(NativeScriptSyncServiceSocketImpl.this.context.getFilesDir(), "internal/livesync.js"), false);
169169
operationReportCode = OPERATION_END_REPORT_CODE;
170170
} else {
171171
operationReportCode = OPERATION_END_NO_REFRESH_REPORT_CODE;

test-app/runtime/src/main/java/com/tns/Runtime.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,10 @@ public void runModule(File jsFile) throws NativeScriptException {
590590
}
591591

592592
public Object runScript(File jsFile) throws NativeScriptException {
593+
return this.runScript(jsFile, true);
594+
}
595+
596+
public Object runScript(File jsFile, final boolean waitForResultOnMainThread) throws NativeScriptException {
593597
Object result = null;
594598

595599
if (jsFile.exists() && jsFile.isFile()) {
@@ -621,7 +625,7 @@ public void run() {
621625
if (success) {
622626
synchronized (r) {
623627
try {
624-
if (arr[1] == null) {
628+
if (arr[1] == null && waitForResultOnMainThread) {
625629
r.wait();
626630
}
627631
} catch (InterruptedException e) {

0 commit comments

Comments
 (0)