Skip to content

Commit

Permalink
Block auto-eval until engine ready (#137)
Browse files Browse the repository at this point in the history
Fixes #136
  • Loading branch information
mfikes authored May 18, 2019
1 parent b7a5141 commit 40a31a3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Replete/ReplViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ class ReplViewController: UIViewController, UITableViewDataSource, UITableViewDe
NSLog("Initializing...");
DispatchQueue.global(qos: .background).async {
appDelegate.initializeJavaScriptEnvironment()
self.initialized = true;
DispatchQueue.main.async {
// mark ready
NSLog("Ready");
self.initialized = true;
let hasText = self.textView.hasText
self.evalButton.isEnabled = hasText
if (hasText) {
Expand Down Expand Up @@ -236,6 +236,9 @@ class ReplViewController: UIViewController, UITableViewDataSource, UITableViewDe

if (enterPressed && range.location == currentText!.count) {
enterPressed = false
while (!self.initialized) {
Thread.sleep(forTimeInterval: 0.1);
}
sendAction()
return false;
}
Expand Down

0 comments on commit 40a31a3

Please sign in to comment.