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

Feature Request: Import code like "require(datapoint)" #1426

Open
heiko3967 opened this issue Oct 28, 2023 · 2 comments
Open

Feature Request: Import code like "require(datapoint)" #1426

heiko3967 opened this issue Oct 28, 2023 · 2 comments

Comments

@heiko3967
Copy link

The desire to structure the code by using modules has been discussed in various forums. But I couldn't find a satisfying solution yet.
I know that I can place my modules somewhere on the file system where iob can find then and require them from there. But that puts the code outside of iob and somehow feels wrong to me.
I also know that I can put my classes in "global". But, apart from he fact that it is no fun to restart the adapter after every change, that just feels, well, too global.
In expert mode, I can see that all my scripts show up under objects as datapoints. That lets me think, that something like require("script.js.common.myStuff") would be an incredibly cool function to have.
Any thoughts?
(I did my research, but I may still have missed the best. So, if you know of an already existing solution to this, please help me find it)

@heiko3967 heiko3967 changed the title Import code like "require(datapoint)" Feature Request: Import code like "require(datapoint)" Oct 28, 2023
@klein0r
Copy link
Collaborator

klein0r commented Apr 1, 2024

Okay, but in that case

  • Those scripts should be of type module and cannot be started or stopped
  • All scripts have to be restarted automatically, if the module scripts change
  • The require function of the sandbox needs to be extended to load and return code of another object

It's a lot of work for a very small target group...

@TrashOne
Copy link

I would also be very happy about the possibility of having a simple way to call "sub-scripts" within a "main script" - so that you could structure extensive code very clearly. My Ideea would be something like this:

  1. all scripts for a project are stored in an extra subfolder in Common
  2. all declared variables (outside functions) are available in all scripts within the extra folder. (same with functions)
  3. Subscripts do not have to be started manually, but are started by a "main script".

In summary its more or less "just" the possability to seperate one big Script into some seperate little scripts which will be called from an Main-Script.

Oh yes, that would be really great :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants