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
New transformer parameter #192
Comments
@vburojevic Hi, as in https://github.com/hyperoslo/Cache#generic-type-safety-and-transformer, although Storage now have different type constraints, they all share the same thing under the hood, the type is to just for safety and extension. You can use method |
Hey! Thanks for a quick answer! Hmm, not sure I get it. Now I have something like this, and just store everything that's Codable into it:
I would preferably have something like this now (but can't pass Codable as type now of course, this is just to illustrate):
I guess one way would be to have TransformerFactory return instance of TransformerFactory.data, but I'll have to deserialize every Codable struct myself to data before saving it to storage? Because I currently have something like this:
Maybe I am missing something though. |
Initially I also was confused. I was using Cache as a generic mechanism in my network library. So the initialization cannot be done with a specific type. I now initialize the Storage with a dummy transformer and in the code that gets and sets values I initiate the transformer in the correct type. So my cashing code now looks like this: The dummy type:
initialization of the cache:
Using the cache in my network layer:
|
@vburojevic Hi, you can't do this |
@onmyway133 yes I know, I mentioned that this was just an illustration. |
@vburojevic yeah, to support multiple types, UIImage, Data, custom types, not just Codable. I could make something called |
Seems cool! |
@onmyway133 Hello, when will u release this feature? :) |
I don't like 3rd |
Was there a change to this feature? I'm having the same issue as everyone, having initialization done with specific type makes it less generic for me. |
I created CacheManager that returns default storage by passing any codable type.
So, you can use it this way:
|
Removing this library from our app. Next time when you want to make changes this like this, you might as well create a different library for a different purpose. |
Docs indicate to have a separate instance of storage for every type in the new version, why?
In the previous version, I used one storage to store all Codable entities, not sure how to migrate it now...
The text was updated successfully, but these errors were encountered: