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

Scope problem for sbots methods #2

Open
ameba23 opened this issue May 27, 2018 · 0 comments
Open

Scope problem for sbots methods #2

ameba23 opened this issue May 27, 2018 · 0 comments

Comments

@ameba23
Copy link
Owner

ameba23 commented May 27, 2018

All sbot methods are called from within a callback from ssb-client.

I can call them from a function by passing the sbot object to it like so: (simplified)

var ssbClient = require('ssb-client')

function publishMessage(sbot, message,recipients) {
  sbot.private.publish(message,recipients,callback)
}

ssbClient(function (err, sbot) {

  publishMessage(sbot,'hello',{ alice, bob })
} )

But when i have a function called from elsewhere, for example an onclick="function()" event in the html, i have no opportunity to pass the sbot object to the function and so sbot's methods are out of scope.

I am wondering if i can get around this by wrapping ssb-client around electron's loadURL:

const electron = require('electron')
const app = electron.app

const BrowserWindow = electron.BrowserWindow

function createWindow () {
  mainWindow = new BrowserWindow({width: 800, height: 600})

  // put this inside ssb-clients callback?
  mainWindow.loadURL(`file://${__dirname}/../html/index.html`)

}

app.on('ready', createWindow)

but still there isnt a way to pass on the sbot object. Any ideas?

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