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

Event Reference Dilemma #6

Open
DawsonReschke opened this issue Feb 26, 2022 · 1 comment
Open

Event Reference Dilemma #6

DawsonReschke opened this issue Feb 26, 2022 · 1 comment

Comments

@DawsonReschke
Copy link
Contributor

DawsonReschke commented Feb 26, 2022

For the JSON parser to work correctly, any external libs must have an internal reference for the compiler to see, for example:

GET=async function(GETURL,POSTURL,callback){
           await axios.get(GETURL).then(val=>callback(POSTURL,GETPARSER(val),(data)=>this.LOG(this.OUTPUT_FILE,data)))
        }

In this example the GET function is making a reference to axios an external library for http requests. Since the JSON converter does not have a reference to this library it cannot compile. This happens because when instanciating a new function with the function constructor, the function is evaluated and has no reference to the external library. To void this, you must have a reference to the requested library in the prototype of the Event, and when you need the library use the prototypes reference to it. Example:

import axios from 'axios'
....
{
  this.axios = axios
  GET=async function(GETURL,POSTURL,callback){
           await this.axios.get(GETURL).then(val=>callback(POSTURL,GETPARSER(val),(data)=>this.LOG(this.OUTPUT_FILE,data)))
 },
}
@DawsonReschke
Copy link
Contributor Author

If not obvious, the reason this is a problem is that if the programmer is not careful, each Event object could have its own reference to a specific library that they ALL use. axios is bad example for this because each Event already had a global reference to the module. One way to get around this would be to create a class that extends the current Event class that adds in references to all of the required modules.

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