question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make it possible for AMPs to handle offline state

See original GitHub issue

Make it possible for AMPs to handle offline state, e.g. by disabling certain actions. A first step could be to listen to changes in connectivity and add a class amp-offline to the body tag <body class="amp-offline ..."> if navigator.onLine === false.

Then elements could be disabled via css:

amp-offline button.disable-when-offline {
  pointer-events: none;
  ...
}

//cc @pbakaus @ericlindley-g

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:12 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
aghassemicommented, Oct 8, 2018

agree with the event as long as we make sure it does not happen on page load. So likely on="onlineStatusChanged:act" instead of on="online:act, offline: act".

AMP trying to detect “real” onlineness is an interesting idea! I am just worried we may not be able to invalidate the state quickly enough without constantly polling an endpoint ( e.g. amp-list initially fails to connect and we set to offline but there isn’t any other XHR from the page anymore and we never go back to online )

We should bring this up with WebPlafroms to see if they can improve accuracy of navigator.onLine based on real data.

1reaction
westonrutercommented, Oct 8, 2018

It would be ideal if the online/offline detection could also account for the lie-fi state, that is, to show offline even though the WiFi is connected. This could conceivably be connected with the XHR service, yes? Any time that an amp-list or amp-live-list etc. tries to load content from the server, it could update some state as to whether requests are failing.

I wonder if having a new amp-offline body class would be enough? It would seem useful to me if there were online and offline events that could be triggered on some element. This would then allow the page to set some state to change the body class and make other changes for offline mode. This would be more powerful than just toggling the body class alone.

Read more comments on GitHub >

github_iconTop Results From Across the Web

25. Replication and High Availability — AMPS User Guide ...
For high availability, you build applications that are fault tolerant: that keep working as designed even when part of the system fails or...
Read more >
16.10 - Down AMP Recovery - Teradata Database
Down AMP Recovery is a process that handles all changes to entire tables or rows, ... The down AMP is considered to be...
Read more >
Audio Architect indicates devices are offline, or how do I go ...
The custom user interface panel's indicators that show online status for devices, such as amps and DSPs, are red or indicate that devices...
Read more >
Actions and events - amp.dev
For example, the following is possible in AMP: ... toggleChecked(force=BOOLEAN), Toggles checked state of the target element. force is optional, ...
Read more >
What is AMP? - The Complete Guide to Accelerated Mobile ...
This comprehensive guide details what AMP (accelerated mobile pages) consist of, the main benefits, how the framework compares to other web pages &...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found