You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to implement an app that consists of just an input field initially, which when submitted will dynamically load a remote script and do something on onload event, using Cell.
More specifically, I was trying to find a way to load a remote cell app from an existing cell app, and inject it into the existing cell app.
But I ran into a problem. When loading a remote script dynamically, it is not possible to know what variables have loaded as a result of that script. The new manual instantiation feature introduced in #125 doesn't help because we have no knowledge about the newly introduced variables in the root context.
Anyway here's the half-finished code. The only problematic part is the Fill in the blank here part inside onload(). Once that's figured out, everything should just work.
{
$cell: true,
_load: function(url) {
this.querySelector("#script_slot").$components.push({
$type: "script",
src: url,
onload: function() {
/*
* Fill in the blank here
* Need to turn the loaded gene objects into cells
* but we do not know what variables have loaded.
*/
}
});
},
$components: [
{
id: "script_slot",
$components: []
},
{
$type: "input",
placeholder: "Enter a javascript url and press enter",
onkeyup: function(e) {
// when the enter key is pressed, find the nearest ancestor
// that contains _load() and call that function.
if(e.keyCode === 13) this._load(this.value);
}
}
]
}
Trying to figure out a nice and clean way to tackle this.
it could be done through a modification of the API, or maybe there's a way to do this without modifying the API. Maybe there's a clean way.
The text was updated successfully, but these errors were encountered:
gliechtenstein
changed the title
[Puzzle] How to know what variables have loaded as a result of a dynamic script load triggered by cell?
[Puzzle] Dynamically loading a remote Cell script from an existing Cell app and injecting into the app.
Jul 8, 2017
gliechtenstein
changed the title
[Puzzle] Dynamically loading a remote Cell script from an existing Cell app and injecting into the app.
Dynamically loading a remote Cell script from an existing Cell app and injecting into the app.
Jul 8, 2017
gliechtenstein
changed the title
Dynamically loading a remote Cell script from an existing Cell app and injecting into the app.
Dynamically loading a remote Cell script from an existing Cell app and injecting into the existing Cell app.
Jul 8, 2017
But the challenge I'm trying to point out here is that currently there's no way to detect whether a variable has already been used or not.
In the example above, we need to detect only the variables that have been dynamically loaded as a result of the script load. The Object.keys(window) approach will return all the variables, not just the newly added ones. Hope I'm making sense, it's a niche scenario but I think it can be powerful if we can figure this out.
I was trying to implement an app that consists of just an input field initially, which when submitted will dynamically load a remote script and do something on
onload
event, using Cell.More specifically, I was trying to find a way to load a remote cell app from an existing cell app, and inject it into the existing cell app.
But I ran into a problem. When loading a remote script dynamically, it is not possible to know what variables have loaded as a result of that script. The new manual instantiation feature introduced in #125 doesn't help because we have no knowledge about the newly introduced variables in the root context.
Anyway here's the half-finished code. The only problematic part is the
Fill in the blank here
part insideonload()
. Once that's figured out, everything should just work.Trying to figure out a nice and clean way to tackle this.
it could be done through a modification of the API, or maybe there's a way to do this without modifying the API. Maybe there's a clean way.
The text was updated successfully, but these errors were encountered: