cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing one expression library functions from another expression lib

ayush_vipul
New Contributor III

Hi

I have a use case where I am looking forward to access methods of one library(expression file) from another library (expression file 2).

Is their a way to achieve this?

1 ACCEPTED SOLUTION

ayush_vipul
New Contributor III

Thanks @tstack

This helped me a lot.
😀

View solution in original post

17 REPLIES 17

No, why would you think that’s the case?

The libraries should be cached in the Snaplex node memory, so having more than one should not affect performance greatly. If you are seeing a performance issue, that might be a bug that needs to be fixed.

ayush_vipul
New Contributor III

Thanks for the help @tstack

ayush_vipul
New 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)

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
    }
}