and also it seems to be slowing down the app by alot, it the http request being like opened in the new isolate or is it in the same ?
how are you handling the documents in your app?
I didn't get it
what's returning empty?
no we're not using a separte isolate, but this is a good suggestion
so, I removed the wrapper, and how I am handling is I expected document to be retuned else it will stuck at loading indicator
please see my original message about optimistic updates
where and how are you using this create method?
I guess I didn't get it this part optimistic updates
could you explain little bit more
Write operations will not resolve until online again. So, if you're offline and you have:
final document = await _database.createDocument();
execution will be stuck at this line until the device goes online again
So, I am follwing repository Arch using Bloc, and what happens is when user click on button it trigger a event that call a Repository function which then call this Centeral Appwrite Repository... dart
Future<Either<Failure, Document>> createBeatInRemote(
CreateBeatRequestModel requestModel,
) async {
try {
final cacheResponse =
await Instance.appwrite.create<CreateBeatRequestModel>(
collectionId: AppwriteCollectionIDs.beat,
requestModel: requestModel,
);
return Right(cacheResponse);
} catch (error) {
return Left(Failure.fromErrorObject(error));
}
}
oh, got it... this seems I would need wrapper but have to handle is different way I think because if Appwrite doesn't return Document then whole app won't work I guess I have to come-up with some other way I think because no matter what need to return object or exception so that repository can then passed to bloc layer which then can notifiy the bloc.
But, I wonder when I try to read the document it it getting returned, then while create why not return the document ?
again, see:
void submitTodo() async {
final messenger = ScaffoldMessenger.of(context);
final newTodo = Todo(
content: inputController.text,
id: ID.unique(),
);
// create optimistically
databases.createDocument(
databaseId: constants.appwriteDatabaseId,
collectionId: constants.appwriteCollectionId,
documentId: newTodo.id,
data: {"content": newTodo.content, "isComplete": newTodo.isComplete},
).catchError((e) {
// handle errors
messenger.showSnackBar(createErrorSnackBar(e.toString()));
todos.remove(newTodo);
});
inputController.text = '';
setState(() {
todos.add(newTodo);
});
}
Notice how the todo
is added to the list of todos
without await
ing the createDocument()
because the resolution happens when the server receives the request and provides the response
right, I am asking while reading in offline we are receving the document right, so why not return that it-self during the creation
you can only resolve a future once and it's reserved for when the server responds
in case there's an error from the server, you can respond accordingly
I got the point, so you are saying if & when internet is back then you receive the document, I guess it make sense, it would be helpful to go-through the RFC & Arch Diagram that will clear doubts... rn just thinking how to twick my Arch to make offine workable
Here's some additional info: https://github.com/appwrite/appwrite/discussions/5326
thank you, this makes sense. I saw some Read.me doc. supper excited to deep dive into it
@Vedsaga I'm just checking if everything is good so we can close this topic (marking it as solved) π
I guess initial test seems to be working fine, so we may can close this. I just eagerly waiting for RFC to re design architecture of my project to support offline. And after that if I stuck somewhere I can create new ticket.
Okay, thank you for updating.
[SOLVED] How to setup offline-online sync and use it in flutter?
Recommended threads
- Apple OAuth Scopes
Hi Hi, I've configured sign in with apple and this is the response i'm getting from apple once i've signed in. I cant find anywhere I set scopes. I remember se...
- Sign In With Apple OAuth Help
Hi All! I've got a flutter & appwrite app which Im trying to use sign in with apple for. I already have sign in with google working and the function is the sam...
- Type Mismatch in AppwriteException
There is a discrepancy in the TypeScript type definitions for AppwriteException. The response property is defined as a string in the type definitions, but in pr...