[RFC] Add a useClient()
hook for writing JS expressions in IDE
#2664
bharatkashyap
announced in
Early feedback
Replies: 2 comments
-
|
Beta Was this translation helpful? Give feedback.
0 replies
-
In this example, it's not completely clear to me whether the whole function would run on the client or server side. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Goal
Being able to write a client-side function in VS Code which has access to the current runtime global scope
Motivation
Instead of having to write client side expressions in the binding editor, I could write those in my IDE as well. We could then have a clean separation of pro-code and drag/drop UI.
Disclaimer
At the outset, this is not to suggest that every single expression of JS should need opening up the editor to write a function. What I propose is that we allow simplistic actions (that would otherwise only require a standard, single Javascript expression) to be achieved from the UI. For instance, attaching rows to a Datagrid; or binding a function to a Button without any customisation.
What I am suggesting is to move the fall-through case – where a user must write code in the UI – to the IDE as well.
Example
For instance, in the
functions.ts
file, we could allow calling auseClient
hook:In the UI, I would then be able to bind the
onClick
handler to the above-defined function, which would use the real-time evaluated values oftext1
anddataGrid2
from the UI.This way, we move complex JavaScript outside the UI and make a clean separation between UI editing and pro-code.
Beta Was this translation helpful? Give feedback.
All reactions