WebView.bindJs

Create a callback in D for a js function.

  1. void bindJs(string jsFunc, void* extra)
    struct WebView
    void
    bindJs
    (
    alias func
    )
    (
    string jsFunc = __traits(identifier, func)
    ,
    void* extra = null
    )
  2. void bindJs(void* extra)

See Also

response, resolve, reject, unbindJs

// Simple callback without params
void hello() { ... }

// Js arguments will be passed as JSON array
void world(JSONValue[] args) { ... }

// You can use the sequence arg to return a response.
void reply(JSONValue[] args, string sequence) { ... resolve(sequence, JSONValue("Hello Js!")); }

webview.bind!hello;          // If you call hello() from js, hello() from D will respond
webview.bind!hello("test")   // If tou call test() from js, hello() from D will respond

Meta