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 awaiting 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
- Does 1.9.0 Self Hosted have MongoDB Atla...
I have been playing with the new 1.9.0 update and I am really excited for the MongoDB support. I wanted to ask though if at the current time Appwrite supports b...
- {"code": 1008, "message": "Invalid Origi...
Nothing has changed in my application or console settings so I'm curious as to what I need to do to fix this. I already have the client registered so I'm not en...
- mcp-server-appwrite 0.4 fails on startup...
Iām trying to use `mcp-server-appwrite` against Appwrite Cloud and the server authenticates successfully, but fails during startup validation when probing `tabl...