hot reloading in ftd #465
amitu
started this conversation in
Ideas & RFCs
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
How can we design ftd such that hot reloading is easy? What about server push stuff? Can we design ftd such that if data changes on server the UI is auto updated, without interrupting the current activity user may be performing?
Developer/Author Hot Reloading
fpm
can watch ftd files for changes, andftd.js
can keep a web socket connection open withfpm
to listen for file changes.What would be sent on this channel so
ftd.js
can update the rendered UI?Fpm will have to keep track of current rendered tree, and when a file changes compute the new tree, and see the delta.
If any text field has changed, we can do a quick update to the dom.
If a component is gone, we can delete it from dom and remove the dependencies.
This may be a preview only feature, only he coders or authors of a site want to see real time preview of changes, they do not want end users to see the content change in real time.
Production Websocket Push
This case deals not with ftd files changing as above. Here the variables are changing. We have dynamic variables getting initialised by processors, or even ftd functions tomorrow.
For each dynamic variable, the system knows that it is dynamic, that it is initialised by some function/processor.
Now ftd can not know the when the changes happen in the dynamic variables, as they may be coming from external APIs, database queries etc. But developer can associate some variable with a signal, say web hook, say the page was index.ftd, variable
user-count
. Now we can have some machinery say,/-/variable-changed/?page=index.ftd&variable=user-count&value=20
, so fpm can be notified that variable has changed and the new value is 20, or may be fpm can re-run the processor and compute the value, so value is not passed only document and variable name.Any browser that is currently showing
index.ftd
and therefor some value of user-count, can be notified about the change inuser-count
, and the UI can be re-rendered.The moment we talk about web socket, and even otherwise in general, depending on load etc, we will not have a single fpm server. So either fpm servers form a gossip-network, and updates to one server is sent to others, or the original that has detected the change gets a list of currently live fpm server, and inform each of them about the change.
Beta Was this translation helpful? Give feedback.
All reactions