Spomky-Labs / phpwa-demo

Demonstration for the PHPWA Bundle
0 stars 1 forks source link

Add ApiPlatform and use stimulus for crud actions #6

Open tacman opened 8 months ago

tacman commented 8 months ago

I'm excited to see a working demo!

I think it can be improved by leveraging stimulus and api platform for the crud actions. In particular, an action like "toggle" shouldn't show a 404 if it's online, but instead should attempt an AJAX call to the API, and when that returns, update the item html.

In the ideal world, actions would update a local database (IndexDB? Firebase?) and a background process would keep the data in sync. But in the short term, it could simply fail but instead of a 404 simply say "try again when you're online".

Fetching the items, too, could be an API call rather than fetching the entire page.

Spomky commented 8 months ago

shouldn't show a 404 if it's online,

With Background Sync the requests are queued. The behavior depends on the application context. The app could simply redirect with a message telling it will be handled later (I think Mercure or Push notifications are great for that).