REQUESTS - Offline Availability
Offline Availability
- Have you ever found a case where you have a cache, but it just doesn’t care about the user’s current network status?
- Have you ever wanted to ensure data is available for your app the next time it launches, but the user is disconnected?
When you are building a mobile app, you need to consider offline availability. This is especially true for apps that are used in the field or in areas where network connectivity is spotty.
Offline should not be considered a “cache”. If online connectivity is detected, the offline middleware will keep making calls to your handler. Consider using the (Caching Middleware)[./caching] if you are looking for a performance based cache setup
Request Handler Example
Controlling HOW the offline data is stored
Often, there are times you want to store data based on the parameter arguments within your request. Trying to build these keys for you can be a bit tricky, so we have a simple interface to help you out instead.
The offline middleware looks at your IRequest implementation. You can also implement the IRequestKey
interface which is part
of the Shiny.Mediator.Contracts library. This allows you to ‘build’ a key from possible arguments in your request object.
Example