supabase / supabase-flutter

Flutter integration for Supabase. This package makes it simple for developers to build secure and scalable products.
https://supabase.com/
MIT License
661 stars 154 forks source link

Ability to save requests offline and reexecute them later. #862

Closed ConProgramming closed 3 months ago

ConProgramming commented 3 months ago

This is very useful for supporting offline mode in apps. Not sure if should be implemented like this, but this works for my use case.

dshukertjr commented 3 months ago

If you want to execute the request in a later time, you can just not call await on the method. Then you can just call await when you actually want to execute it.

final request = supabase.from('table').select();

... some time later
final data = await request;
ConProgramming commented 3 months ago

I need to serialize the request to Json to save offline. Saving it to a HiveBloc

dshukertjr commented 3 months ago

@ConProgramming Cool. You can create your own extension method to implement this for your particular use case if you are not doing it already. Unfortunately, we will not add support for these methods on this SDK.

ConProgramming commented 3 months ago

What's the recommended way to do that? I thought I would have to patch SDK

dshukertjr commented 3 months ago

You can read about extension methods here: https://dart.dev/language/extension-methods

ConProgramming commented 3 months ago

Thanks

ConProgramming commented 3 months ago

It seems extension methods won't work, because I cannot override private methods.

Is this possible without updating the sdk?

dshukertjr commented 3 months ago

Right, I missed that.

Is this possible without updating the SDK?

I suppose not. You can fork the repo, add the feature, and add the package to your Flutter app. https://stackoverflow.com/questions/54022704/how-to-add-a-package-from-github-in-flutter