Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

outputstream emits no data #9

Open
serapath opened this issue Jan 7, 2017 · 0 comments
Open

outputstream emits no data #9

serapath opened this issue Jan 7, 2017 · 0 comments

Comments

@serapath
Copy link

serapath commented Jan 7, 2017

i'm using the following code snippet with node v5.11.0, electron v1.4.13 and electron-microscope v2.0.0

I hope i'm not using it wrong. I'd be happy for a hint why the output$ stream is not logging anything.

var electron = require('electron')
var createMicroscope = require('electron-microscope')

electron.app.on('ready', function () {
  createMicroscope(function (err, scope) {
    if (err) throw err
    var url = 'http://google.de'
    var code = '(function () { return document.title || "m3h" })()'
    var microscope = scope.window.webContents
    function cb (result) { console.log(result) }

    scope.loadURL(url, function () {
      microscope.executeJavaScript(code, false, cb)

      var CODE = `function (send, done) {
        // put your custom code here
        // call 'send(data)' to write data to the stream
        // call 'done()' to end the stream
        // calling send is optional, but you must eventually call done to end the stream
        send(document.title)
        send('asdf')
        done()
      }`
      var output$ = scope.run(CODE)
      // @TODO: `output$` emits no data :/
      output$.on('data', function (data) { console.log('data: ',arguments) })
      output$.on('error', function (err) { console.error(err) })
    })
  })
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant