Closed prologic closed 2 years ago
You can poll the server or even use a websocket and reload the page when it reports a newer version. But I think you want to warn the user. Simply reloading the website while somebody is working with the app seems disruptive. So you can tell the user that an update is there and let him choose if he wants to update.
@oderwat So to be clear, I'm talking about an installed PWA here.
But what you're saying is this is basically just application logic? Build some mechanism that pings back to "some palce to get updates" and if there's an update, prompt the user and do something to reload the the app?
Q: How does one (in Go) issue the hard-reload (which I guess is required)?
The installed PWA is nothing else than a web browser in disguise. It will update the same as if it is inside of the normal browser. See also: https://go-app.dev/lifecycle
You could just use some timer to request the current version from the server. I used a script that did head requests for the resources and then reloaded the page. But I now use a web socket subscription model to communicate between the server and different clients. So the server can also tell them about available updates.
Thanks! I'd appreciate if you were to document or blog post about how you went about supporting this in your own apps. Otherwise I'm sure I can work something out too 👌 Thanks heaps!
PS: You don't want to write this app for me do you? I can pay you :D (a bit)
@prologic I would love to have more time for experimental stuff like go-app. We are investing time and money (= paying our developers) to experiment with it and sponsor this project officially. Sadly I am mostly only documenting techniques internally and in code. We have a rather complex prototype application in the works but are still evaluating it for productive usage.
@oderwat If I may ask, if you're evaluating go-app for feasibility in an app at your company, what's the decision making process like? what has your team worked out so far? I've known about go-app and wasm for quite some years now, and I'm pretty much settled on using go-app for this project.
Other choices like Flutter and what not are honestly garbage, Flutter recently broke their entire framework breaking a whole bunch of people's code (including mind), which I just don't have time for that kind of nonsense (admittedly it was the Android ecosystem that changes, bt still).
@prologic Funny that you mention Flutter. We used this for a project last year and even when this was quite successful I didn't want to continue using it. To make it short: I "wish" to have front and backend code written in the same "stable" language and the language chosen is Go (for different reasons). My biggest concern with go-app and WASM is that the scope of some of the planned projects is just too big (ERP) and WASM is going to break in a hard-to-understand way. I already had some strange results with code getting too big (WASM can't be loaded and run because module size gets too big), browsers suddenly not working anymore (updated Chrome did not load the same App), and such nonsense. So currently we are trying to test the limits, figuring out how to work around them, and at the same time implement some of the more complex components like interactive combo boxes or stuff like calendar widgets. I also kinda re-implement parts of a framework I develop for 20 years (PHP-based) that is currently the backbone for our bigger software and has proven to be "timeless". I can not really tell what the actual decision process will be. The most important thing is, that we feel good about it :). I have two seniors (including me) and a (very) junior developer experimenting with it on and off for some months now.
How big is 'too big" here?
I mean my initial thoughts on this, are "find a balance" don't build everything in the (what is effectively) as Wasm?
Sorry if this is the wrong place to ask, but how does one go about implementing some kind of self-updating app? If I push a new version of the app out to my
app.domain
where it has a newapp.wasm
and other things, how do I get the installed pwa to notice there's a new version and self-updated itself?This is crucial for me to be able to iterate on something I'm working on
Actually... I'm going to answer my own question 😂 Turns out there is a ctx.IsAppUpdateAvailable() method on the app.Context
interface and you can then call `app.Reload().
I'm going to give this a try 👌
How big is 'too big" here?
Well, this is the question and you need to have an answer. We can not tell a client that the functionality is not available because of technology limits from using WASM while the same will work with AngularJS or Vue/React.
Umm 🤔 I'm not sure you can compare Web Assembly with Javascript UI frameworks 😅 (apples vs. oranges and all that)
Actually... I'm going to answer my own question 😂 Turns out there is a ctx.IsAppUpdateAvailable() method on the
app.Context
interface and you can then call `app.Reload().
Did you look at https://go-app.dev/lifecycle, which I pointed you at in my second comment? I thought it was already known. The problem is that the app will not show you that there is an update without checking for it, and for this, the user needs to navigate to another URL (outside the WASM router) or re-open (or reload) it. I thought you were looking for an answer to the problem with a long-running app. I believe the app can solve this by calling "reg. update()" on the web-worker regularly and notifying the user. An alternative is adding an outside mechanism to reload the page twice or implementing skip waiting in the service worker (which can be referred to as hard reload).
See: https://web.dev/service-worker-lifecycle/
This is what I worry about:
Umm 🤔 I'm not sure you can compare Web Assembly with Javascript UI frameworks 😅 (apples vs. oranges and all that)
But go-app is a replacement for a javascript UI framework?
I just created #705 so you can see how an update check can be done with long-running PWAs that are not (re-)loading the pages from the server.
Very nice! 👌
Sorry if this is the wrong place to ask, but how does one go about implementing some kind of self-updating app? If I push a new version of the app out to my
app.domain
where it has a newapp.wasm
and other things, how do I get the installed pwa to notice there's a new version and self-updated itself?This is crucial for me to be able to iterate on something I'm working on