Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create request caching service #280

Open
Tracked by #298
ethan-tbd opened this issue Aug 29, 2024 · 8 comments · May be fixed by #315
Open
Tracked by #298

Create request caching service #280

ethan-tbd opened this issue Aug 29, 2024 · 8 comments · May be fixed by #315

Comments

@ethan-tbd
Copy link
Contributor

This request caching service will be used to:

  1. make requests to url
  2. return cached data for url
  3. request new data from backend at url
  4. update cache for url

callers of this will get two responses, like a stream of data where the first response is the cached response and the second response is the network response

perhaps using this as a custom hook similar to https://tanstack.com/query/latest

@aashish-g03
Copy link

.take

Copy link

github-actions bot commented Oct 5, 2024

Thanks for taking this issue! Let us know if you have any questions!

@aashish-g03
Copy link

@ethan-tbd,

I have implemented a solution that closely matches your requirements. You can find the example code here:

Flutter Caching Hook GitHub Repository

Please review it and let me know if it meets your needs. Additionally, I've provided a recording of the implementation for your reference:

caching.screen.record.mp4

Approach:

  1. Used SharedPreferences to store cache data persistently across sessions.
  2. Utilized streams to send multiple responses from the function, ensuring that the first response is the cached data and the subsequent one is the fresh network data.
  3. Updated the UI with StreamBuilder based on the data received from the stream, providing a seamless user experience.

@ethan-tbd
Copy link
Contributor Author

please create a pr to include this request caching service in the lib/shared folder!

@blackgirlbytes
Copy link

@aashish-g03 Hey there! I'm just checking up if you were able to create a PR or if you need some help. Your effort wont be counted for hacktoberfest if you don't create a PR, and I want to make sure you get credit!

@aashish-g03
Copy link

Thank you for the reminder, @blackgirlbytes! I’ll create a PR and share it with you shortly.

@taniashiba
Copy link
Contributor

Just checking back in on your PR, @aashish-g03 . Let us know if you need any help or have any questions! ❤

aashish-g03 added a commit to aashish-g03/didpay that referenced this issue Oct 15, 2024
@aashish-g03 aashish-g03 linked a pull request Oct 15, 2024 that will close this issue
@aashish-g03
Copy link

@taniashiba, I have submitted a PR with the requested service. Apologies for the slight delay, as I took the time to thoroughly refine the code, enhancing both readability and ensuring it is production-ready. I appreciate your patience, and I would like to extend a special thanks to @blackgirlbytes, @taniashiba, and @ethan-tbd for your support throughout the process.

Working through this repository has been an invaluable learning experience, offering deep insights into GitHub automations, code structure, the use of hermit, command executions, and maintaining high standards of code quality.

I am eager to contribute further to projects within the organization, particularly with Flutter or other intriguing technologies. If there are additional feature requests or areas where I can assist, I would be happy to help. Thank you once again for this opportunity.

aashish-g03 added a commit to aashish-g03/didpay that referenced this issue Oct 17, 2024
aashish-g03 added a commit to aashish-g03/didpay that referenced this issue Nov 1, 2024
feat: add tests for request caching service (TBD54566975#280)

fix: fix box import and tests for request caching service (TBD54566975#280)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants