Re: Static data for web pages

You could always take a look at this pattern for loading state from the server, and picking it up on the client

https://github.com/cris691/servedata/blob/master/_views/loginlink.js#L19

Cris
________________________________
From: Melvin Carvalho <melvincarvalho@gmail.com>
Sent: Sunday, May 10, 2020 5:09 PM
To: TAG List <www-tag@w3.org>; Tim Berners-Lee <timbl@w3.org>
Subject: Static data for web pages

Hi Tag

I wanted to ask about a possible data model for the web.  Whether it exists, or whether or not it's a good idea.

It revolves around the popular idea of Single Page Applications (SPA) and "static" data.  Single pages applications written in JS are well understood, I am going to consider an app without routes, so truly a "single page" SPA..

State management is a common challenge.  Where the state of the app is kept in a self contained store of some kind.

The problem is that when you reload the app the store will reset itself and the variables will not remember where they were when they left off.

Other languages have a solution for this called "static" variables.  Ones that remain constant to a degree.  But I dont think we have "static" variables on the web, AFAIK.

A typical work around to this would be to have some kind of REST API with a server running to maintain that API and perhaps a bearer token to authenticate and allow you to save state.  That's quite an overhead.

What if, instead an SPA were to have a static part.  Perhaps readers of this list are familiar with "data islands", a bunch of data that is stored in a script tag and is global.  This could be in turn used to initialize the app.

What if you could use that global data to bootstrap your SPA and indeed change it, and keep it persistent.  A method to do this could be along Timbl's ideas of a read write web where you send a bearer token and PUT the data back to the page you are looking at.  But only change the data island.  The app itself could be a single line shim.

Could this be a solution to create persistent static data for web pages and single pages apps, on the web?

Would love to hear if there's any existing solutions to this, or any feedback

Best
Melvin

Received on Thursday, 28 May 2020 09:38:43 UTC