Live Javascript Editing

Do not post support requests, bug reports or feature requests. Discuss CEF here. Non-CEF related discussion goes in General Discussion!

Live Javascript Editing

Postby damo » Mon Nov 17, 2014 11:58 pm

So basically I have an application where I want to allow the users to have client side scripts where they can edit in the application and save and edit and it becomes instantly live. I have thought about various ways to do this but everything I can think of has some pitfalls or I don't know the workings of V8 well enough to know the best way to go about it.

In the scripts users will be able to subscribe to events which are fired from within C++ back to javascript. If I re-evaluate the users script after they have edited it I don't want any previous code to still fire if these events are called.

Is there a way to do this so that V8 will dispose of the previous code? Even if it makes it invalid somehow I could always check in the Event system if the callback function is still valid and if it isn't then just get rid of it.

Any help would be greatly appreciated :)

[Edit]
Another thought I had was if I could somehow run it in its own context? But still have some global functions available to it ie the event system? Then "clear" the context when the user updates the script?
damo
Newbie
 
Posts: 8
Joined: Thu Jan 09, 2014 3:40 am

Re: Live Javascript Editing

Postby magreenblatt » Tue Nov 18, 2014 12:03 am

Maybe load the script in an iframe? It will get a new context on creation/reload and can be mixed with other content for display.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: Live Javascript Editing

Postby damo » Tue Nov 18, 2014 12:05 am

Great idea, thanks I will try it out and see how I go :)
damo
Newbie
 
Posts: 8
Joined: Thu Jan 09, 2014 3:40 am


Return to CEF Discussion

Who is online

Users browsing this forum: No registered users and 44 guests