-
Hello! I have recently stumbled upon a situation where I am not sure what the best/correct solution is. The issue I'm having is that I do not have image URLs to use for AsyncImage and the like. Our company's API provides an endpoint where I can retrieve image data by entity ID. This API only accepts POST requests where the required token is provided in the request body, and the actual endpoint is specified in the tokenized request. Furthermore, the data this endpoint provides is not cached, so I will have to do this on the client end. My idea so far is as follows:
The downside to this approach is that I'll be storing image data in TCA state, which does not "feel" correct. Not only that: image data will be repeated in memory as both the image cache and the state will contain image data. Another approach that I've theorized is one where I share some sort of image cache between TCA and SwiftUI (as dependency and environment). The view can then wait for the image cache to contain the thumbnail, and I can use TCA to set image data in the image cache if needed. I'd be happy with any comments on my solutions as well as any other solutions I may not have thought of. :) EDIT: Added some additional information about the API. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
You can make a cache client which stores the images off the state to memory or disk and juste store the local url / cache key to the tca state. When the key switch to non nil load the image from the cache. |
Beta Was this translation helpful? Give feedback.
You can make a cache client which stores the images off the state to memory or disk and juste store the local url / cache key to the tca state. When the key switch to non nil load the image from the cache.