Project level reusable functions syntax

for business objects to call a reusable behavior…what’s the syntax?
Docs for Reusable Behavior
can’t seem to get it addressable…
I have a reusable behavior named getIcon() which returns a string…
Tried a few things
this.apexAppService.someReusableFunction() doesn’t work.
this.someReusableFunction() doesn’t…

I’ve tried to add the getIcon() function as a dependency on a UI Component, but it doesn’t have it in the list…

Reusable behaviors are a server-side only construct. To use them, you create the behavior and then add it as a dependency to your server-side business object behavior.

If you want to have a reusable function for the client-side, you would create a user interface service and add the function as a method on that service. To use it in a user interface method, you would add the service as a dependency and then call it with syntax like this:

const result = this.myService.myfunc()

can a UI Service call a reusable function?
In other words, is there a way to define some logic one time, and call it either from a business object or from a UI Page/Component/Service?

Apex Design does not currently give you a metadata way to do this. You probably could have a Files directory containing functions common to both the client side and server side and then import them into a page or a server-side behavior.

1 Like