6

I'm using Weinre to debug an iPad App and was looking for a JS callback from Weinre that signals when Weinre has finished loading and e.g. it's safe to use its console object in my code.

I looked through the docs and the target-script.js that hooks Weinre into my page but couldn't find anything.

Any help would be appreciated.

flu
  • 14,307
  • 8
  • 74
  • 71
  • 1
    Same problem, did you figured out a way? – Caio Cunha Mar 04 '13 at 17:08
  • 1
    @CaioToOn: Unfortunately no. Right now I'm waiting 500ms before using e.g. `console.log()` which works in my debug environment. As Weinre will be removed in production anyway I use this workaround until I find a solution that feels trustworthy ;) – flu Mar 04 '13 at 17:36
  • Another approach is to put your init code into a function, and call this function from a remote console - this way you'll be sure the console is initailized – Kukunin Jan 24 '19 at 03:14

1 Answers1

1

I think by "safe to use the console" object, you mean, when will writing to the console object start writing to the remote console window. If so, that's a tough proposition, as your app might NEVER connect to a client debugger. Or the client debugger might connect, then disconnect, then connect, ... There would really need to be two events - weinreConnected and weinreDisconnected, or some such.

I didn't want to have to add new events to the system, but if there's a lot of interest, we can probably make it happen. Feel free to open a Jira issue for a new feature.

Patrick Mueller
  • 697
  • 1
  • 6
  • 13