title: javascript function callback in C code using Emscripten
body: <p>The task is to call a javascript function as a callback in order to show a progress of while-loop operation.
  E.g.
  JS:</p>
  
  <pre><code>var my_js_fn = function(curstate, maxstate){//int variables
  console.log(curstate.toString() + " of " + maxstate.toString());
  }
  </code></pre>
  
  <p>C  pseudocode:</p>
  
  <pre><code>int smth_that_calls_my_fn(int i, int max) {
  /*
  the_magic to call my_js_fn()
  */
  }
      int main(){
      //....
          while (i &lt; max){
          smth_that_calls_my_fn(i,max);
          }
      //....
      return 0;
      }
  </code></pre>
  
  <p>How can I link <code>smth_that_calls_my_fn</code> and <code>my_js_fn</code> ?</p>