+ Appwrite Offline allows your client apps to continue functioning without an internet connection. Your users' mobile devices frequently encounter situations where internet access becomes unstable or temporarily unavailable, like when going through tunnels, getting on airplanes and subways, or going in and out of WIFI range. Offline helps your app gracefully handle these real life situations and keep your users engaged.
+
+
+
When Should I Enable Offline?
+
+ Appwrite Offline allows you to continue making requests to Appwrite APIs while offline through a cache. While offline, read requests will be fetched from the local cache data, and write requests will be queued and executed once the device is online again.
+
+
+ You should consider enabling Offline if you expect the user device running your application to experience short periods without a network connection, like going on an airplane to going through a tunnel. Offline can't help you if the app's data needs to remain up to date with frequent updates or if write requests need to be processed immediately. If you expect you app to be offline for days or weeks at a time, you may also need to find alternative solutions.
+
+
+
Tradeoffs of Enabling Offline
+
+ Offline support adds a cache layer that takes up additional resources and adds overhead to your requests. This may not be desirable for some applications, especially if it's not expected to be used without a stable internet connection.
+
+
+ When Offline is enabled, it will change how promises are resolved in the Appwrite SDKs. Requests made Offline can become blocking, which means you will need to change how you handle promises in your application. This means you may need to rewrite some of your code when adding Offline to existing applications.
+
\ No newline at end of file
From a46cc354cbc0ff88d2f9122486a6420e8b12ecdc Mon Sep 17 00:00:00 2001
From: "Vincent (Wen Yu) Ge"
Date: Thu, 26 Jan 2023 17:45:30 -0500
Subject: [PATCH 03/30] Update app/views/docs/offline.phtml
Co-authored-by: Steven <1477010+stnguyen90@users.noreply.github.com>
---
app/views/docs/offline.phtml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/docs/offline.phtml b/app/views/docs/offline.phtml
index 547adf384..f80010c84 100644
--- a/app/views/docs/offline.phtml
+++ b/app/views/docs/offline.phtml
@@ -1,5 +1,5 @@
- Appwrite Offline allows your client apps to continue functioning without an internet connection. Your users' mobile devices frequently encounter situations where internet access becomes unstable or temporarily unavailable, like when going through tunnels, getting on airplanes and subways, or going in and out of WIFI range. Offline helps your app gracefully handle these real life situations and keep your users engaged.
+ The Appwrite SDKs' Offline Support allows your client apps to continue functioning without an internet connection. Your users' mobile devices frequently encounter situations where internet access becomes unstable or temporarily unavailable, like when going through tunnels, getting on airplanes and subways, or going in and out of Wi-Fi range. Offline Support helps your app gracefully handle these real-life situations and keeps your users engaged.
When Should I Enable Offline?
From a5cf410b799d18a436a21fc2d2a1fe0c88ebb28a Mon Sep 17 00:00:00 2001
From: "Vincent (Wen Yu) Ge"
Date: Thu, 26 Jan 2023 17:45:36 -0500
Subject: [PATCH 04/30] Update app/views/docs/offline.phtml
Co-authored-by: Steven <1477010+stnguyen90@users.noreply.github.com>
---
app/views/docs/offline.phtml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/docs/offline.phtml b/app/views/docs/offline.phtml
index f80010c84..78fb35619 100644
--- a/app/views/docs/offline.phtml
+++ b/app/views/docs/offline.phtml
@@ -2,7 +2,7 @@
The Appwrite SDKs' Offline Support allows your client apps to continue functioning without an internet connection. Your users' mobile devices frequently encounter situations where internet access becomes unstable or temporarily unavailable, like when going through tunnels, getting on airplanes and subways, or going in and out of Wi-Fi range. Offline Support helps your app gracefully handle these real-life situations and keeps your users engaged.
-
When Should I Enable Offline?
+
When Should I Enable Offline Support?
Appwrite Offline allows you to continue making requests to Appwrite APIs while offline through a cache. While offline, read requests will be fetched from the local cache data, and write requests will be queued and executed once the device is online again.
From 2cc25998695b7c6866fc02eb3cf2db5ae00c71e9 Mon Sep 17 00:00:00 2001
From: "Vincent (Wen Yu) Ge"
Date: Thu, 26 Jan 2023 17:45:44 -0500
Subject: [PATCH 05/30] Update app/views/docs/offline.phtml
Co-authored-by: Steven <1477010+stnguyen90@users.noreply.github.com>
---
app/views/docs/offline.phtml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/docs/offline.phtml b/app/views/docs/offline.phtml
index 78fb35619..d3b844af1 100644
--- a/app/views/docs/offline.phtml
+++ b/app/views/docs/offline.phtml
@@ -7,7 +7,7 @@
Appwrite Offline allows you to continue making requests to Appwrite APIs while offline through a cache. While offline, read requests will be fetched from the local cache data, and write requests will be queued and executed once the device is online again.
- You should consider enabling Offline if you expect the user device running your application to experience short periods without a network connection, like going on an airplane to going through a tunnel. Offline can't help you if the app's data needs to remain up to date with frequent updates or if write requests need to be processed immediately. If you expect you app to be offline for days or weeks at a time, you may also need to find alternative solutions.
+ You should consider enabling Offline Support if you expect the user device running your application to experience short periods without a network connection, like going on an airplane or through a tunnel. Offline can't help you if the app's data needs to remain up to date with frequent updates or if write requests need to be processed immediately. If you expect your app to be offline for days or weeks at a time, you may also need to find alternative solutions.
- Appwrite Offline allows you to continue making requests to Appwrite APIs while offline through a cache. While offline, read requests will be fetched from the local cache data, and write requests will be queued and executed once the device is online again.
+ With Offline Support enabled, your app can continue sending requests to Appwrite APIs while offline through a cache. While offline, read requests will be fetched from the local cache data, and write requests will be queued and executed once the device is online again.
You should consider enabling Offline Support if you expect the user device running your application to experience short periods without a network connection, like going on an airplane or through a tunnel. Offline can't help you if the app's data needs to remain up to date with frequent updates or if write requests need to be processed immediately. If you expect your app to be offline for days or weeks at a time, you may also need to find alternative solutions.
From c84c16071a56f32ec3c27e6ebd56884d9f5077c9 Mon Sep 17 00:00:00 2001
From: "Vincent (Wen Yu) Ge"
Date: Thu, 26 Jan 2023 17:46:07 -0500
Subject: [PATCH 07/30] Update app/views/docs/offline.phtml
Co-authored-by: Steven <1477010+stnguyen90@users.noreply.github.com>
---
app/views/docs/offline.phtml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/docs/offline.phtml b/app/views/docs/offline.phtml
index 9d40cf1ed..01751ed20 100644
--- a/app/views/docs/offline.phtml
+++ b/app/views/docs/offline.phtml
@@ -10,7 +10,7 @@
You should consider enabling Offline Support if you expect the user device running your application to experience short periods without a network connection, like going on an airplane or through a tunnel. Offline can't help you if the app's data needs to remain up to date with frequent updates or if write requests need to be processed immediately. If you expect your app to be offline for days or weeks at a time, you may also need to find alternative solutions.
-
Tradeoffs of Enabling Offline
+
Tradeoffs of Enabling Offline Support
Offline support adds a cache layer that takes up additional resources and adds overhead to your requests. This may not be desirable for some applications, especially if it's not expected to be used without a stable internet connection.
From 4894a138468c51898f1b14c5f6daaa7bce9850ce Mon Sep 17 00:00:00 2001
From: "Vincent (Wen Yu) Ge"
Date: Thu, 26 Jan 2023 17:46:13 -0500
Subject: [PATCH 08/30] Update app/views/docs/offline.phtml
Co-authored-by: Steven <1477010+stnguyen90@users.noreply.github.com>
---
app/views/docs/offline.phtml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/docs/offline.phtml b/app/views/docs/offline.phtml
index 01751ed20..dd98bf41a 100644
--- a/app/views/docs/offline.phtml
+++ b/app/views/docs/offline.phtml
@@ -15,5 +15,5 @@
Offline support adds a cache layer that takes up additional resources and adds overhead to your requests. This may not be desirable for some applications, especially if it's not expected to be used without a stable internet connection.
- When Offline is enabled, it will change how promises are resolved in the Appwrite SDKs. Requests made Offline can become blocking, which means you will need to change how you handle promises in your application. This means you may need to rewrite some of your code when adding Offline to existing applications.
+ When Offline Support is enabled, it will change how API calls are made in the Appwrite SDKs. Write requests made while offline will not return until online again, which means you will need to change how you call these methods in your application. This means you may need to rewrite some of your code when adding Offline Support to existing applications.
\ No newline at end of file
From 69e5c823d0c2c07622c6476d1dba8e21f02dd2c7 Mon Sep 17 00:00:00 2001
From: "Vincent (Wen Yu) Ge"
Date: Thu, 26 Jan 2023 22:53:22 +0000
Subject: [PATCH 09/30] Rewrite trade offs + existing projects
---
app/views/docs/offline.phtml | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/app/views/docs/offline.phtml b/app/views/docs/offline.phtml
index dd98bf41a..fba136423 100644
--- a/app/views/docs/offline.phtml
+++ b/app/views/docs/offline.phtml
@@ -2,7 +2,7 @@
The Appwrite SDKs' Offline Support allows your client apps to continue functioning without an internet connection. Your users' mobile devices frequently encounter situations where internet access becomes unstable or temporarily unavailable, like when going through tunnels, getting on airplanes and subways, or going in and out of Wi-Fi range. Offline Support helps your app gracefully handle these real-life situations and keeps your users engaged.
-
When Should I Enable Offline Support?
+
When Should I Enable Offline Support?
With Offline Support enabled, your app can continue sending requests to Appwrite APIs while offline through a cache. While offline, read requests will be fetched from the local cache data, and write requests will be queued and executed once the device is online again.
@@ -10,10 +10,11 @@
You should consider enabling Offline Support if you expect the user device running your application to experience short periods without a network connection, like going on an airplane or through a tunnel. Offline can't help you if the app's data needs to remain up to date with frequent updates or if write requests need to be processed immediately. If you expect your app to be offline for days or weeks at a time, you may also need to find alternative solutions.
-
Tradeoffs of Enabling Offline Support
+
Considerations and Tradeoffs
- Offline support adds a cache layer that takes up additional resources and adds overhead to your requests. This may not be desirable for some applications, especially if it's not expected to be used without a stable internet connection.
+ Offline Support adds a cache layer that takes up additional resources and adds overhead to your requests. This may not be desirable for some applications, especially if it's not expected to be used without a stable internet connection.
+
Offline Support for Existing Projects
- When Offline Support is enabled, it will change how API calls are made in the Appwrite SDKs. Write requests made while offline will not return until online again, which means you will need to change how you call these methods in your application. This means you may need to rewrite some of your code when adding Offline Support to existing applications.
+ Promises may not resolve immediately when Offline Support is enabled. Existing projects will require some code to be rewritten when adopting Offline Support. Learn more about promise resolution.
\ No newline at end of file
From ae66a2ba4af2bd8d006eaf4e4ffbb51b2b022f91 Mon Sep 17 00:00:00 2001
From: "Vincent (Wen Yu) Ge"
Date: Mon, 6 Feb 2023 11:05:40 -0500
Subject: [PATCH 10/30] Update app/views/docs/offline.phtml
Co-authored-by: Bradley Schofield
---
app/views/docs/offline.phtml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/docs/offline.phtml b/app/views/docs/offline.phtml
index fba136423..c072e2f44 100644
--- a/app/views/docs/offline.phtml
+++ b/app/views/docs/offline.phtml
@@ -7,7 +7,7 @@
With Offline Support enabled, your app can continue sending requests to Appwrite APIs while offline through a cache. While offline, read requests will be fetched from the local cache data, and write requests will be queued and executed once the device is online again.
- You should consider enabling Offline Support if you expect the user device running your application to experience short periods without a network connection, like going on an airplane or through a tunnel. Offline can't help you if the app's data needs to remain up to date with frequent updates or if write requests need to be processed immediately. If you expect your app to be offline for days or weeks at a time, you may also need to find alternative solutions.
+ You should consider enabling Offline Support if you expect the user device running your application to experience short periods without a network connection, like going on an airplane or through a tunnel. Offline Support can't help you if the app's data needs to remain up to date with frequent updates or if write requests need to be processed immediately. If you expect your app to be offline for days or weeks at a time, you may also need to find alternative solutions.
- Promises may not resolve immediately when Offline Support is enabled. Existing projects will require some code to be rewritten when adopting Offline Support. Learn more about promise resolution.
+ Asynchronous operations may not resolve immediately when Offline Support is enabled. Existing projects will require some code to be rewritten when adopting Offline Support. Learn more about how to handle asynchronous operation.
\ No newline at end of file
From 8c0b39e89d9514590975fa3eef637a839592b433 Mon Sep 17 00:00:00 2001
From: "Vincent (Wen Yu) Ge"
Date: Fri, 10 Feb 2023 13:26:23 -0500
Subject: [PATCH 12/30] Update app/views/docs/offline.phtml
Co-authored-by: Steven <1477010+stnguyen90@users.noreply.github.com>
---
app/views/docs/offline.phtml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/docs/offline.phtml b/app/views/docs/offline.phtml
index 37d099efb..aba188cef 100644
--- a/app/views/docs/offline.phtml
+++ b/app/views/docs/offline.phtml
@@ -4,7 +4,7 @@
When Should I Enable Offline Support?
- With Offline Support enabled, your app can continue sending requests to Appwrite APIs while offline through a cache. While offline, read requests will be fetched from the local cache data, and write requests will be queued and executed once the device is online again.
+ With Offline Support enabled, your app can continue sending requests to Appwrite APIs while offline through a cache. While offline, read requests will be fetched from the local cached data, and write requests will be queued and executed once the device is online again.
You should consider enabling Offline Support if you expect the user device running your application to experience short periods without a network connection, like going on an airplane or through a tunnel. Offline Support can't help you if the app's data needs to remain up to date with frequent updates or if write requests need to be processed immediately. If you expect your app to be offline for days or weeks at a time, you may also need to find alternative solutions.
From 5828b058e7a9fe2814b87101579ec8b0635ef054 Mon Sep 17 00:00:00 2001
From: "Vincent (Wen Yu) Ge"
Date: Fri, 10 Feb 2023 13:26:38 -0500
Subject: [PATCH 13/30] Update app/views/docs/offline.phtml
Co-authored-by: Steven <1477010+stnguyen90@users.noreply.github.com>
---
app/views/docs/offline.phtml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/docs/offline.phtml b/app/views/docs/offline.phtml
index aba188cef..8fd3a603f 100644
--- a/app/views/docs/offline.phtml
+++ b/app/views/docs/offline.phtml
@@ -7,7 +7,7 @@
With Offline Support enabled, your app can continue sending requests to Appwrite APIs while offline through a cache. While offline, read requests will be fetched from the local cached data, and write requests will be queued and executed once the device is online again.
- You should consider enabling Offline Support if you expect the user device running your application to experience short periods without a network connection, like going on an airplane or through a tunnel. Offline Support can't help you if the app's data needs to remain up to date with frequent updates or if write requests need to be processed immediately. If you expect your app to be offline for days or weeks at a time, you may also need to find alternative solutions.
+ You should consider enabling Offline Support if you expect the device running your application to experience short periods without a network connection, like going on an airplane or through a tunnel. Offline Support can't help you if the app's data needs to remain up to date with frequent updates or if write requests need to be processed immediately. If you expect your app to be offline for days or weeks at a time, you may also need to find alternative solutions.
Considerations and Tradeoffs
From ba58a55652a3524a5c8a49baede116ad35c2de5a Mon Sep 17 00:00:00 2001
From: "Vincent (Wen Yu) Ge"
Date: Fri, 10 Feb 2023 21:16:28 +0000
Subject: [PATCH 14/30] Plan body of offline doc
---
app/views/docs/offline.phtml | 51 +++++++++++++++++++++++++++++++-----
1 file changed, 44 insertions(+), 7 deletions(-)
diff --git a/app/views/docs/offline.phtml b/app/views/docs/offline.phtml
index 8fd3a603f..fb43f1714 100644
--- a/app/views/docs/offline.phtml
+++ b/app/views/docs/offline.phtml
@@ -4,17 +4,54 @@
When Should I Enable Offline Support?
- With Offline Support enabled, your app can continue sending requests to Appwrite APIs while offline through a cache. While offline, read requests will be fetched from the local cached data, and write requests will be queued and executed once the device is online again.
+ You should consider enabling Offline Support if you expect the device running your application to experience short periods without a network connection, like going on an airplane or through a tunnel. Offline Support can't help you if the app's data needs to remain up to date with frequent updates or if write requests need to be processed immediately. If you expect your app to be offline for days or weeks at a time, you may also need to find alternative solutions.
+
+
Enable Offline Support
- You should consider enabling Offline Support if you expect the device running your application to experience short periods without a network connection, like going on an airplane or through a tunnel. Offline Support can't help you if the app's data needs to remain up to date with frequent updates or if write requests need to be processed immediately. If you expect your app to be offline for days or weeks at a time, you may also need to find alternative solutions.
+
-
Considerations and Tradeoffs
- Offline Support adds a cache layer that takes up additional resources and adds overhead to your requests. This may not be desirable for some applications, especially if it's not expected to be used without a stable internet connection.
+ Offline Support can be enabled by setting setOffilnePersistency to true on your SDK's client.
-
Offline Support for Existing Projects
+
+[TODO: Code Example]
- Asynchronous operations may not resolve immediately when Offline Support is enabled. Existing projects will require some code to be rewritten when adopting Offline Support. Learn more about how to handle asynchronous operation.
-
\ No newline at end of file
+ Offline Support will cache all read request in a Least Recently Used (LRU) cache, so the information can remain available even with no internet connection. The LRU cache defaults to a size of 16KB and can be configured using the setOfflineCacheSize method.
+
+
+[TODO: Code Example]
+
+
Asynchronous Operation
+
+ When Offline Support is enabled, asynchronous operations only resolve after the request is accepted by the server. Requests made with the Client SDK may block code execution until network connection is available again.
+
+[TODO: Show UML diagram]
+
+
+ For example, the code example below will block code execution when the device is offline.
+
+
+[TODO: Show Example, in comments clearly mark that it's ]
+
+
+ To avoid blocking code execution, asynchronous operations should be handled [TODO: fill description]
+
+
+[TODO: Show correct version of example. ]
+
+
Conflict Resolution
+
+ With Offline Support enabled, your app can continue sending requests to Appwrite APIs while offline through a cache when offline. Read requests will be fetched from the local cached data, and write requests will be queued and executed once the device is online again. This can lead to write conflicts when the device is online again.
+
+
+ [TODO: Describe resolution behavior + tips if available.]
+
+
+
+ Additional considerations need to be considered when updating data based on the current value, such as incrementing a counter or appending values to then end of a paragraph. The default conflict resolution behavior may result in incorrect updates and writes. Consider disabling these operations while offline or use Appwrite Functions to implement logic to resolve conflicts.
+
+
+
+
From e6ed7e089d3e2ca0ebfe0f441c70b8a0a0b008ae Mon Sep 17 00:00:00 2001
From: "Vincent (Wen Yu) Ge"
Date: Fri, 10 Feb 2023 21:24:10 +0000
Subject: [PATCH 15/30] Special care for async ops in a notice
---
app/views/docs/offline.phtml | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/app/views/docs/offline.phtml b/app/views/docs/offline.phtml
index fb43f1714..c5548e9ff 100644
--- a/app/views/docs/offline.phtml
+++ b/app/views/docs/offline.phtml
@@ -8,14 +8,17 @@
Enable Offline Support
-
-
-
Offline Support can be enabled by setting setOffilnePersistency to true on your SDK's client.
+
+
Adding Offline Support to Existing Projects
+
Enabling Offline Support introduces breaking changes to the behavior of Client SDKs. Asynchronous operations may not resolve until the device is online again. Existing projects will have to be updated.
Offline Support will cache all read request in a Least Recently Used (LRU) cache, so the information can remain available even with no internet connection. The LRU cache defaults to a size of 16KB and can be configured using the setOfflineCacheSize method.
@@ -23,7 +26,7 @@
[TODO: Code Example]
-
Asynchronous Operation
+
Asynchronous Operation
When Offline Support is enabled, asynchronous operations only resolve after the request is accepted by the server. Requests made with the Client SDK may block code execution until network connection is available again.
- When Offline Support is enabled, asynchronous operations only resolve after the request is accepted by the server. Requests made with the Client SDK may block code execution until network connection is available again.
+ When Offline Support is enabled, asynchronous write operations only resolve after the server accepts the request. Requests made with the Client SDK may block code execution until network connection is available again.
- Offline Support will cache all read request in a Least Recently Used (LRU) cache, so the information can remain available even with no internet connection. The LRU cache defaults to a size of 16KB and can be configured using the setOfflineCacheSize method.
+ Offline Support will cache all read request in a Least Recently Used (LRU) cache, so the information can remain available even with no internet connection. The LRU cache defaults to a size of 16MB and can be configured using the setOfflineCacheSize method.
Offline Support will cache all read request in a Least Recently Used (LRU) cache, so the information can remain available even with no internet connection. The LRU cache defaults to a size of 16MB and can be configured using the setOfflineCacheSize method.
-[TODO: Code Example]
+
+
client.setOfflineCacheSize(40000);
+
Asynchronous Operation
@@ -35,14 +39,28 @@
For example, the code example below will block code execution when the device is offline.
-
-[TODO: Show Example, in comments clearly mark that it's ]
+
+
// This await will not resolve until your device is online
+final document = await databases.createDocument(
+ databaseId: '[DATABASE_ID]',
+ collectionId: '[COLLECTION_ID]',
+ documentId: ID.unique(),
+ data: {},
+);
+
- To avoid blocking code execution, asynchronous operations should be handled [TODO: fill description]
+ To avoid blocking code execution, update local states and UI optimisitically instead of waiting for awaiting asynchronous operations.
From 8e66831a70a00476566ed89ea36f7ff2183e99b9 Mon Sep 17 00:00:00 2001
From: "Vincent (Wen Yu) Ge"
Date: Wed, 8 Mar 2023 20:26:50 +0000
Subject: [PATCH 19/30] update description for conflict resolution
---
app/views/docs/offline.phtml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/docs/offline.phtml b/app/views/docs/offline.phtml
index 89c15a14e..a14642ca3 100644
--- a/app/views/docs/offline.phtml
+++ b/app/views/docs/offline.phtml
@@ -67,7 +67,7 @@ final document = await databases.createDocument(
With Offline Support enabled, your app can continue sending requests to Appwrite APIs while offline through a cache when offline. Read requests will be fetched from the local cached data, and write requests will be queued and executed once the device is online again. This can lead to write conflicts when the device is online again.
- [TODO: Describe resolution behavior + tips if available.]
+ Document updates made while your device is offline will be queued locally with a timestamp. When your device comes online, Appwrite will compare the timestamps of local updates with the timestamp of the remote document, accepting the latest version. Appwrite will reject a document update if the remote document been updated later than the locally queued update.
From 0c0680e77f87977a0ef381dac2c395fc3bc47102 Mon Sep 17 00:00:00 2001
From: "Vincent (Wen Yu) Ge"
Date: Wed, 8 Mar 2023 23:11:27 +0000
Subject: [PATCH 20/30] Adds information about the state
---
app/views/docs/offline.phtml | 68 +++++++++++++++++++++++++++++-------
1 file changed, 55 insertions(+), 13 deletions(-)
diff --git a/app/views/docs/offline.phtml b/app/views/docs/offline.phtml
index a14642ca3..de7a01301 100644
--- a/app/views/docs/offline.phtml
+++ b/app/views/docs/offline.phtml
@@ -40,13 +40,34 @@
For example, the code example below will block code execution when the device is offline.
-
// This await will not resolve until your device is online
-final document = await databases.createDocument(
- databaseId: '[DATABASE_ID]',
- collectionId: '[COLLECTION_ID]',
- documentId: ID.unique(),
- data: {},
-);
- The Appwrite SDKs' Offline Support allows your client apps to continue functioning without an internet connection. Your users' mobile devices frequently encounter situations where internet access becomes unstable or temporarily unavailable, like when going through tunnels, getting on airplanes and subways, or going in and out of Wi-Fi range. Offline Support helps your app gracefully handle these real-life situations and keeps your users engaged.
+ Offline Support allows your client apps to continue functioning without an internet connection. Mobile devices frequently encounter situations where internet access becomes unstable or temporarily unavailable, like going through tunnels, getting on airplanes and subways, or going in and out of Wi-Fi range. Offline Support keeps your users engaged when transitioning through these real-life situations.
- You should consider enabling Offline Support if you expect the device running your application to experience short periods without a network connection, like going on an airplane or through a tunnel. Offline Support can't help you if the app's data needs to remain up to date with frequent updates or if write requests need to be processed immediately. If you expect your app to be offline for days or weeks at a time, you may also need to find alternative solutions.
+ You should consider enabling Offline Support if you expect the device running your application to experience short periods without a network connection, like going on an airplane or through a tunnel.
-
-
Enable Offline Support
-
- Offline Support can be enabled by setting setOffilnePersistency to true on your SDK's client.
+ Offline Support can't help you if the app's data needs to remain up to date with frequent updates or if write requests need to be processed immediately. If you expect your app to be offline for days or weeks, you may need to find alternative solutions.
Enabling Offline Support introduces breaking changes to the behavior of Client SDKs. Asynchronous operations may not resolve until the device is online again. Existing projects will have to be updated.
+ You can enable Offline Support by setting setOffilnePersistency to true on your SDK's client.
+
+
client.setOfflinePersistency(status: true);
+
+
Configure Cache
- Offline Support will cache all read request in a Least Recently Used (LRU) cache, so the information can remain available even with no internet connection. The LRU cache defaults to a size of 16MB and can be configured using the setOfflineCacheSize method.
+ Offline Support will cache all read requests in a Least Recently Used (LRU) cache, so the information can remain available without internet connection. The LRU cache defaults to 16MB and can be configured using the setOfflineCacheSize method.
- When Offline Support is enabled, asynchronous write operations only resolve after the server accepts the request. Requests made with the Client SDK may block code execution until network connection is available again.
+ When Offline Support is enabled, write operations only resolve after the server accepts the request. Requests made with the Client SDK may block code execution until network connection is available again.
+
+
+ You should optimistically update your app's local state after a write operation. Once you're online again, the write will be synced with your Appwrite project, which will be fetched when you app restarts in the future.
+
- With Offline Support enabled, your app can continue sending requests to Appwrite APIs while offline through a cache when offline. Read requests will be fetched from the local cached data, and write requests will be queued and executed once the device is online again. This can lead to write conflicts when the device is online again.
-
- Document updates made while your device is offline will be queued locally with a timestamp. When your device comes online, Appwrite will compare the timestamps of local updates with the timestamp of the remote document, accepting the latest version. Appwrite will reject a document update if the remote document been updated later than the locally queued update.
+ With Offline Support enabled, your app can continue sending requests to Appwrite APIs while offline through a cache when offline. Read requests will be fetched from the locally cached data. Write requests will be queued and executed once the device is online again. This can lead to conflicts if another device makes a different change.
+
How Appwrite Handles Offline Writes
+
- Additional considerations need to be considered when updating data based on the current value, such as incrementing a counter or appending values to then end of a paragraph. The default conflict resolution behavior may result in incorrect updates and writes. Consider disabling these operations while offline or use Appwrite Functions to implement logic to resolve conflicts.
+ Document updates made while your device is offline will be queued locally with a timestamp. When your device comes online, Appwrite will use the timestamps to accept the latest version of the document. Appwrite will reject a document update if the remote document has been updated later than the local document.
-
-
+
Special Cases
+
+ Additional considerations need to be considered when updating data based on the current value, such as incrementing a counter or appending values to the end of a paragraph. The default conflict resolution behavior may result in incorrect updates and writes. Consider disabling these operations while offline or using Appwrite Functions to implement logic to resolve conflicts.
+
\ No newline at end of file
From 2fc9646dd61a2e49fd7ef1ba40ac19e4b747fdcd Mon Sep 17 00:00:00 2001
From: "Vincent (Wen Yu) Ge"
Date: Mon, 13 Mar 2023 22:48:26 +0000
Subject: [PATCH 22/30] Update example for Flutter
---
app/views/docs/offline.phtml | 28 ++++------------------------
1 file changed, 4 insertions(+), 24 deletions(-)
diff --git a/app/views/docs/offline.phtml b/app/views/docs/offline.phtml
index 01c3f8c7c..fca610bef 100644
--- a/app/views/docs/offline.phtml
+++ b/app/views/docs/offline.phtml
@@ -67,13 +67,7 @@ $image = new View(__DIR__.'/../general/image.phtml');
For example, the code example below will block code execution when the device is offline.
-
void blockingSubmitTodo() async {
- if (inputController.text.isEmpty || isLoading) return;
- final messenger = ScaffoldMessenger.of(context);
- final newTodo = Todo(
- content: inputController.text,
- id: ID.unique(),
- );
+
+When Offline Support is enabled, Appwrite allows you to query and write data by adding a cache layer.
+
+
+
Reading Data Offline
+
+ Queries will fetch data from Appwrite and update the cache while the device is online. If the device is not connected to the internet, the query fetches data from the local cache.
+
+
+
+
+
+
+
Writing Data Offline
+
+ Writes will update the local cache first. If the device is online, the changes will be sent to Appwrite immediately. If the device is not connected to the internet, the operation will be queued and synced to Appwrite when internet is available again.
+
When Offline Support is enabled, write operations only resolve after the server accepts the request. Requests made with the Client SDK may block code execution until network connection is available again.
-
+
+
+
You should optimistically update your app's local state after a write operation. Once you're online again, the write will be synced with your Appwrite project, which will be fetched when you app restarts in the future.
For example, the code example below will block code execution when the device is offline.
@@ -74,10 +88,10 @@ $image = new View(__DIR__.'/../general/image.phtml');
await _databases.createDocument(
databaseId: '[DATABASE_ID]',
collectionId: '[COLLECTION_ID]',
- documentId: newTodo.id,
+ documentId: todo.id,
data: todo,
);
- todos.add(newTodo);
+ todos.add(todo);
} catch (e) {
// ... handle errors
}
@@ -99,14 +113,14 @@ $image = new View(__DIR__.'/../general/image.phtml');
_databases.createDocument(
databaseId: '[DATABASE_ID]',
collectionId: '[COLLECTION_ID]',
- documentId: newTodo.id,
+ documentId: todo.id,
data: todo,
).catchError((e) {
// ... handle errors
});
setState(() {
- todos.add(newTodo);
+ todos.add(todo);
isLoading = false;
});
}
From 759ffbb2d1a3888dfc275a0aa45caf7052de9a30 Mon Sep 17 00:00:00 2001
From: "Vincent (Wen Yu) Ge"
Date: Mon, 15 May 2023 19:54:05 +0000
Subject: [PATCH 24/30] Relative linkes
---
app/views/docs/offline.phtml | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/app/views/docs/offline.phtml b/app/views/docs/offline.phtml
index e29158ae2..77ee2fc5c 100644
--- a/app/views/docs/offline.phtml
+++ b/app/views/docs/offline.phtml
@@ -8,7 +8,7 @@ use Appwrite\Utopia\View;
Offline Support allows your client apps to continue functioning without an internet connection. Mobile devices frequently encounter situations where internet access becomes unstable or temporarily unavailable, like going through tunnels, getting on airplanes and subways, or going in and out of Wi-Fi range. Offline Support keeps your users engaged when transitioning through these real-life situations.
-
You should consider enabling Offline Support if you expect the device running your application to experience short periods without a network connection, like going on an airplane or through a tunnel.
@@ -16,12 +16,12 @@ use Appwrite\Utopia\View;
Offline Support can't help you if the app's data needs to remain up to date with frequent updates or if write requests need to be processed immediately. If you expect your app to be offline for days or weeks, you may need to find alternative solutions.
-
When Offline Support is enabled, write operations only resolve after the server accepts the request. Requests made with the Client SDK may block code execution until network connection is available again.
@@ -126,7 +126,7 @@ When Offline Support is enabled, Appwrite allows you to query and write data by
}
-
With Offline Support enabled, your app can continue sending requests to Appwrite APIs while offline through a cache when offline. Read requests will be fetched from the locally cached data. Write requests will be queued and executed once the device is online again. This can lead to conflicts if another device makes a different change.
From 6648bffaa15deb5d3ba6b4ed09267ff6a69849d3 Mon Sep 17 00:00:00 2001
From: "Vincent (Wen Yu) Ge"
Date: Mon, 15 May 2023 20:17:41 +0000
Subject: [PATCH 25/30] test image container
---
app/views/docs/offline.phtml | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/app/views/docs/offline.phtml b/app/views/docs/offline.phtml
index 77ee2fc5c..a69d1c074 100644
--- a/app/views/docs/offline.phtml
+++ b/app/views/docs/offline.phtml
@@ -52,9 +52,15 @@ When Offline Support is enabled, Appwrite allows you to query and write data by
Queries will fetch data from Appwrite and update the cache while the device is online. If the device is not connected to the internet, the query fetches data from the local cache.
-
-
-
+setParam('srcLight', '/images-ee/docs/offline-read-uml-light.png')
+ ->setParam('srcDark', '/images-ee/docs/offline-read-uml-dark.png')
+ ->setParam('alt', 'Function settings page.')
+ ->setParam('description', 'Function settings page.')
+ ->render();
+?>
Writing Data Offline
From bb3ccb82af08ff76d6f323737530cc545c657bff Mon Sep 17 00:00:00 2001
From: "Vincent (Wen Yu) Ge"
Date: Mon, 15 May 2023 21:06:31 +0000
Subject: [PATCH 26/30] Update to 6 images
---
app/views/docs/offline.phtml | 23 ++++++++---------------
1 file changed, 8 insertions(+), 15 deletions(-)
diff --git a/app/views/docs/offline.phtml b/app/views/docs/offline.phtml
index a69d1c074..c3de49fcd 100644
--- a/app/views/docs/offline.phtml
+++ b/app/views/docs/offline.phtml
@@ -52,32 +52,25 @@ When Offline Support is enabled, Appwrite allows you to query and write data by
Queries will fetch data from Appwrite and update the cache while the device is online. If the device is not connected to the internet, the query fetches data from the local cache.
Writes will update the local cache first. If the device is online, the changes will be sent to Appwrite immediately. If the device is not connected to the internet, the operation will be queued and synced to Appwrite when internet is available again.
When Offline Support is enabled, write operations only resolve after the server accepts the request. Requests made with the Client SDK may block code execution until network connection is available again.
-
-
-
+
+
+
You should optimistically update your app's local state after a write operation. Once you're online again, the write will be synced with your Appwrite project, which will be fetched when you app restarts in the future.
From cdeff777cc7ed4bb015300145f2eba97d4c29097 Mon Sep 17 00:00:00 2001
From: "Vincent (Wen Yu) Ge"
Date: Mon, 15 May 2023 21:14:25 +0000
Subject: [PATCH 27/30] Fix width
---
app/views/docs/offline.phtml | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/app/views/docs/offline.phtml b/app/views/docs/offline.phtml
index c3de49fcd..d2e97e56c 100644
--- a/app/views/docs/offline.phtml
+++ b/app/views/docs/offline.phtml
@@ -52,8 +52,8 @@ When Offline Support is enabled, Appwrite allows you to query and write data by
Queries will fetch data from Appwrite and update the cache while the device is online. If the device is not connected to the internet, the query fetches data from the local cache.
-
-
+
+
Writing Data Offline
@@ -61,15 +61,15 @@ When Offline Support is enabled, Appwrite allows you to query and write data by
Writes will update the local cache first. If the device is online, the changes will be sent to Appwrite immediately. If the device is not connected to the internet, the operation will be queued and synced to Appwrite when internet is available again.
-
-
+
+
When Offline Support is enabled, write operations only resolve after the server accepts the request. Requests made with the Client SDK may block code execution until network connection is available again.
-
-
+
+
You should optimistically update your app's local state after a write operation. Once you're online again, the write will be synced with your Appwrite project, which will be fetched when you app restarts in the future.
From d1f66fb005313417161cbda0638ec6493af81d17 Mon Sep 17 00:00:00 2001
From: "Vincent (Wen Yu) Ge"
Date: Mon, 15 May 2023 21:18:59 +0000
Subject: [PATCH 28/30] Fix broken HTML tags
---
app/views/docs/offline.phtml | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/app/views/docs/offline.phtml b/app/views/docs/offline.phtml
index d2e97e56c..acd853816 100644
--- a/app/views/docs/offline.phtml
+++ b/app/views/docs/offline.phtml
@@ -52,8 +52,8 @@ When Offline Support is enabled, Appwrite allows you to query and write data by
Queries will fetch data from Appwrite and update the cache while the device is online. If the device is not connected to the internet, the query fetches data from the local cache.
-
-
+
+
Writing Data Offline
@@ -61,15 +61,15 @@ When Offline Support is enabled, Appwrite allows you to query and write data by
Writes will update the local cache first. If the device is online, the changes will be sent to Appwrite immediately. If the device is not connected to the internet, the operation will be queued and synced to Appwrite when internet is available again.
-
-
+
+
When Offline Support is enabled, write operations only resolve after the server accepts the request. Requests made with the Client SDK may block code execution until network connection is available again.
-
-
+
+
You should optimistically update your app's local state after a write operation. Once you're online again, the write will be synced with your Appwrite project, which will be fetched when you app restarts in the future.
From 68a8f4fdfac8f964289db5ef1bbce5f184166c61 Mon Sep 17 00:00:00 2001
From: "Vincent (Wen Yu) Ge"
Date: Tue, 16 May 2023 19:28:42 +0000
Subject: [PATCH 29/30] Change back to the old style of image view
---
app/views/docs/offline.phtml | 37 ++++++++++++++++++++++++++++-------
app/views/general/image.phtml | 15 +++++++++++---
2 files changed, 42 insertions(+), 10 deletions(-)
diff --git a/app/views/docs/offline.phtml b/app/views/docs/offline.phtml
index acd853816..8c8058b75 100644
--- a/app/views/docs/offline.phtml
+++ b/app/views/docs/offline.phtml
@@ -52,24 +52,47 @@ When Offline Support is enabled, Appwrite allows you to query and write data by
Queries will fetch data from Appwrite and update the cache while the device is online. If the device is not connected to the internet, the query fetches data from the local cache.
Writes will update the local cache first. If the device is online, the changes will be sent to Appwrite immediately. If the device is not connected to the internet, the operation will be queued and synced to Appwrite when internet is available again.
When Offline Support is enabled, write operations only resolve after the server accepts the request. Requests made with the Client SDK may block code execution until network connection is available again.