Forum Discussion
You should be able to reference the other library through the lib
variable. Is that not working?
For example, if you this as the library helper.expr
:
{
chefify: x => x + ' bork! bork! bork!'
}
You should be able to reference it from another library, like so:
{
msg: () => lib.helper.chefify('Hello, World!')
}
Note that if the references are not in functions, but directly in the top-level expression, you’ll need to ensure the libraries are listed in the right order in the pipeline properties.
Is there a way to declare methods with global scope in expression library.
Is nesting multiple libraries together a good preactice ?
- tstack7 years agoFormer Employee
Do you mean without the
lib.libname
prefix? No, libraries are always imported under thelib
object.I’m not sure what you mean by this, can you give an example?
- ayush_vipul7 years agoNew Contributor III
lib1 is used by lib2 and then libe2 is used by lib3
referencing multiple library through the
lib
variable- tstack7 years agoFormer Employee
I think it’s fine to reference one library from another.
- ayush_vipul7 years agoNew Contributor III
Hi @tstack by global scope in my query. I meat I have a expression file where we can decalre a function on top level which could be accessed from anywhere in the object(same expression file) using something like globalthis Or this (basically " this context" which would resolve at any herarical level throughout the file)
- tstack7 years agoFormer Employee
I think I understand now… Take a look at the Object Literal documentation where it mentions some of the variables that you can use to reference other parts of a nested literal. I think probably want to use
__root__
for your situation.Maybe something like the following (I haven’t tried it out):
{ value: 42, child: { adder: x => __root__.value + x } }