Call TypeScript RPC in form class

12 views
Skip to first unread message

Wouter Hendriks

unread,
Jan 22, 2025, 9:05:37 AMJan 22
to General WebHare developers discussion
I like being able to do this:

class Form extends RPCFormBase {
 ...
    await this.invokeRPC("prefill"); 

WHLIB: PUBLIC MACRO RPC_Prefill()

To keep the logic in the same folder as the form (page.ts / page.whlib)

Is there an option to do the same but directly calling a TS RPC? So I can have a folder with files like:

account.ts
account.rpc.ts.  <== 'prefill' function here
account.witty

(probably not but you never know)


Arnold Hendriks

unread,
Jan 22, 2025, 3:13:29 PMJan 22
to General WebHare developers discussion
Sounds like a neat idea, but not sure if it's a good idea :-)

I don't think there's currently any way for frontend TS code to reliably detect which file it's in unless by explicitly using __dirname/__filename (especially as the bundler breaks stack traces and you don't want to rely on sourcemaps). Otherwise you could build something similar to test.invoke() which accepts any path and just invokes the code (with a few precautions/checks)

Reply all
Reply to author
Forward
0 new messages