Live data from Hacker News

Offline First – A Better HTML5 User Experience

joelambert.co.uk

31–40 of 150 posts

Re: Offline First – A Better HTML5 User Experience

#32
post #18

The most useful pattern I know of for offline web apps is the command queue. Basically, the rendered state of the client is the acknowledged server state plus the client-side command queue. User actions don't make a server request and then update the UI. Instead they directly append to the local command queue, which updates the UI state, and right away the client begins communicating with the server to make the local…

Yes, This. I struggled with understanding how I'd deal with a complex offline multi user collaborative web app until I starting looking at in terms of a Kafka queue. Gives you everything, including undo/history.

Any suggestions on front end frameworks?

Re: Offline First – A Better HTML5 User Experience

#33
post #13
post #6

Earlier quoted context omitted.

If you need to build cross-platform apps - and that is mostly the case nowadays - the web is actually not such a bad solution. I mean, what is the alternative?

There is plenty of software that works across Windows/Mac/Linux/Unix-like platforms. They run faster, don't always need an internet connection, are easily portable, and are typically better designed and less bloated than any web-limited cross-platform application. They also don't rely on browser cache or localStorage for settings and I don't need to login daily to access my stuff. Disable your web cache and try to us…

> Disable your web cache and try to use a web application daily.

That's like saying "disable a native applications persistent storage and use it daily." It is a meaningless comment.

Re: Offline First – A Better HTML5 User Experience

#34
post #12

tldr: Someone wrote a bunch of paragraphs and LOC around JSON.parse(window.localStorage.getItem(key)). If you're really interested in learning about creating a workable offline web app, Google has some great documentation. https://developers.google.com/web/fundamentals/instant-and-o... Last, the Safari team needs to seriously get to work on Service Workers. We will see web apps grow by leaps and bounds once the servi…

> We will see web apps grow by leaps and bounds once the service worker spec is opened up to iPhone users.

Sounds exactly like what Apple doesn't want; no 30% revenue cut, no walled garden of control, ...

Re: Offline First – A Better HTML5 User Experience

#35
post #14
post #13

Earlier quoted context omitted.

There is plenty of software that works across Windows/Mac/Linux/Unix-like platforms. They run faster, don't always need an internet connection, are easily portable, and are typically better designed and less bloated than any web-limited cross-platform application. They also don't rely on browser cache or localStorage for settings and I don't need to login daily to access my stuff. Disable your web cache and try to us…

Aren't there lots of caveats for each platform when using so called "cross-platform" code?

yes. There can be a lot of boilerplate code present, however in terms of speed, using Qt for instance, can be much faster still than a web application that accomplishes the same task even if you get a huge binary after compilation.

Oh and as Nadya said, sometimes this generalization causes issues. Engineering is a game of trade-offs I think :P.

Re: Offline First – A Better HTML5 User Experience

#36
post #18

The most useful pattern I know of for offline web apps is the command queue. Basically, the rendered state of the client is the acknowledged server state plus the client-side command queue. User actions don't make a server request and then update the UI. Instead they directly append to the local command queue, which updates the UI state, and right away the client begins communicating with the server to make the local…

Yes, This. I struggled with understanding how I'd deal with a complex offline multi user collaborative web app until I starting looking at in terms of a Kafka queue. Gives you everything, including undo/history. Any suggestions on front end frameworks?

I implemented such a solution in a React app and I really appreciated the ability to apply pending state changes without mutating the state itself.

I don't know of any open source libraries for the command queue itself. If your state changing commands go through some kind of layer that you control then this stuff is easier. When I implemented it, I first refactored all the commands to go through the same code path, which I could then modify to implement the queue.

Re: Offline First – A Better HTML5 User Experience

#37
post #3

I sense a trend of trying to cram everything good about native apps onto the web. Do people who do this stop to think whether the web is actually the correct platform for their app?

There are more developers for the web than for C++ GUI applications. Building a cross-platform application using C++ is not a simple task in the slightest and it's even more difficult finding talented developers to accomplish the goal.

It seems like a no-brainer to me, building a cross-platform application use web technologies makes the most sense from a business pov.

Re: Offline First – A Better HTML5 User Experience

#38
post #26
post #19

Earlier quoted context omitted.

I suspect that using Promise.all() helps greatly with this.

The way I've done it is to just have an array of commands and a simple queue thing that keeps retrying its head element until success, triggered by connectivity change or manual user retry. (This was also useful when our backend had random issues causing 500s sometimes.) A command has both an AJAX request and a state updating function. It's really easy with a React-like framework because you can just apply the comman…

Yeah, look into using Promise.all. You're probably looking at a good few hundred lines of code reduction. What you're describing as a "command" (request / state update) is just a promise with a map function applied. Your "simple queue thing" can just be an array that you fire Promise.all at.

Re: Offline First – A Better HTML5 User Experience

#39
post #6

Earlier quoted context omitted.

If you need to build cross-platform apps - and that is mostly the case nowadays - the web is actually not such a bad solution. I mean, what is the alternative?

Gtk Qt The list is actually quite extensive: https://en.wikipedia.org/wiki/List_of_platform-independent_G... -- For mobile, clean separations also helps. It is definitely possible - and less complex than you'd expect - to have core functionality in a shared library, wired up to platform-specific native GUI toolkits. But your question illustrates the problem. The pervasive presence of toolkits that add layer upon laye…

I'm mainly an app developer that transitioned (a long time ago) from native to web apps, tired of code duplication. I'm well aware of other options.

The web comes with its warts, but I've yet to see an app platform as ergonomic and comfortable for the developer as the web. For 99% of my use cases, anything else is overkill and too much of a hassle. It's not the web's fault that it's a better app platform than actual app platforms.

Re: Offline First – A Better HTML5 User Experience

#40
post #3

I sense a trend of trying to cram everything good about native apps onto the web. Do people who do this stop to think whether the web is actually the correct platform for their app?

There is a huge number of applications for which the web is pretty much the only platform that makes any sense at all.

Compared to making a cross platform native application that works on Linux, Mac, Windows, Android, and iOS, making a web app—even with offline support—is delightful and efficient.

Post reply on HN