         println("Error: Method '\(method)' not found in extension '\(name)'")
     }
 }
+
+extension XWalkExtension {
+    // Helper functions to evaluate JavaScript
+    public func evaluate(string: String) {
+        evaluate(string, success: nil)
+    }
+    public func evaluate(string: String, error: ((NSError)->Void)?) {
+        evaluate(string, completionHandler: { (obj, err)->Void in
+            if err != nil { error?(err) }
+        })
+    }
+    public func evaluate(string: String, success: ((AnyObject!)->Void)?) {
+        evaluate(string, completionHandler: { (obj, err) -> Void in
+            err == nil ? success?(obj) : println("ERROR: Failed to execute script, \(err)")
+            return    // To make compiler happy
+        })
+    }
+    public func evaluate(string: String, success: ((AnyObject!)->Void)?, error: ((NSError!)->Void)?) {
+        evaluate(string, completionHandler: { (obj, err)->Void in
+            err == nil ? success?(obj) : error?(err)
+            return    // To make compiler happy
+        })
+    }
+    public func evaluate(string: String, completionHandler: ((AnyObject!, NSError!)->Void)?) {
+        webView.evaluateJavaScript(string, completionHandler: completionHandler)
+    }
+}

public class XWalkExtension: NSObject, WKScriptMessageHandler {
    public final let name: String!
    public final weak var webView: WKWebView!
    private final var properties: Dictionary<String, AnyObject> = [:]

    public init(name: String) {
        super.init()

            let val: AnyObject = value ?? NSNull()
            //properties.updateValue(val, forKey: name)
            let json = JSON(val).rawString()!
            let cmd = "\(self.name).\(name) = \(json); \(self.name).\(name);"
            self.evaluate(cmd, success: { (obj)->Void in
                self.properties.updateValue(obj, forKey: name)
                return
            })
        }
    }
