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

Possible to pass function into client evalSync? #126

Open
ghost opened this issue May 29, 2014 · 0 comments
Open

Possible to pass function into client evalSync? #126

ghost opened this issue May 29, 2014 · 0 comments

Comments

@ghost
Copy link

ghost commented May 29, 2014

From what I understand of the code, it's not possible to pass functions as parameters into evalSync for the client... because the parameters eventually get stringified by phantom and that means only valid JSON types can be passed.

I'm trying to achieve something like this...

helpers = require("./lib/helpers.js");
...
client.evalSync(function() {
    helpers.initialise();
    emit("return");
});

Obviously this isn't going to work, because "helpers" isn't defined after the evalSync function is injected. I don't want to put the emit in the helpers.initialise function because I'm trying to keep my library code free from the concept of Laika.
I tried some closure tricks, but I always ended up clobbering the scope for either 'helpers.initialise' or the 'emit'.

Hoping for some input on this one.

@ghost ghost changed the title Possible to pass object into client evalSync? Possible to pass complex object into client evalSync? May 29, 2014
@ghost ghost changed the title Possible to pass complex object into client evalSync? Possible to pass function into client evalSync? May 29, 2014
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

0 participants