let's say I have the following Java code.
get("/", (request, response) -> {
Map<String, Object> attributes = new HashMap<>();
//attributes.put("message", "Hello World!");
return new ModelAndView(attributes, "index.ftl");
}, new FreeMarkerEngine());
That is from Spark. When I navigate to localhost:portnumber/, I see index.ftl rendered, which let's assume (not coded here) displays data from a database for this app. But let's say I wanted to dynamically update index.ftl. Let's say another user updated the database (not coded here) from another instance of the application, and I wanted to display the new changes in index.ftl on the first user's page. How would this be done without having to re-render the pages?
You can't just simply have a timer in the Java side which pulls in the new data every 10-20 milliseconds. That would be a massive waste of connection time as well. Can the Java code be pinged somehow that the database has been updated? Like a listener for the database?
Not only is that a problem, but how would you be able to push the newly received data to index.ftl without having to rerender?