How can perform CRUD operation in Angular if my application running online as well offline

web application connect with internet that only one time we need internet at the time of login if we have login and few min or hour internet disconnected but we have to perform CRUD operation without internet maybe we again connect internet so our data will send our DB but here is one worst case is that after perform CRUD operation need to submit record to DB but we did not get connect to net our app so how can we get our CRUD operation record manually and save in DB.

in point: At Angular 7 or latest

  1. How web application perform online/offline both at same time.
  2. if login after few minutes we disconnect internet but we have need complete CRUD operation task and after complete need to submit when net connect.
  3. worst case we did not get connection internet so how can manually we can submit record at DB

You might need to figure a “polling system” - something that checks if the online connection is valid, or is slow, or is non-existent. Basically, if you don’t get any response from a front-end ping (say you set up an endpoint in your API that just tells you if its live or not), then you need to create a queue of requests for the back-end.

A solid alternative, when the backend is down, is to queue requests and store them in localStorage. While that queue has pending requests, simply use a setTimeout and check if the server is back up yet and, when it is, process through that queue.

A great book that discusses just this (older, but still very valid) is Dustin Diaz’ “Pro Javascript Design Patterns”, by APress.

1 Like

thankyou for reply but i want know that can Angualr service worker or ngrx can help me any way?