
Having done development across web and native, I've always loved Kotlin, but missed the ease of use of global caching libraries like React Query and SWR. Compose SWR does a great job of getting things almost all the way there in most cases (thanks kazakago if you're in here), but lacked a few things that I've been looking for:
- A bring your own UI framework approach
- Typed optimistic update functions
- Typed refetch functions
As an exploration exercise to see if this could be useful to others, I started CacheOnHand! It's very early, but I'd love to get some other input. It looks to do the following:
- Modularization that allows for taking ONLY what you need
- No enforcement of UI framework - the barebones are compose agnostic
- A familiar API for users coming from a react query, or an SWR like framework
- Transactional optimistic cache updates, that can rollback on error. Allowing for a snappy UI experience
- Tools operating on your cache as a Query, Mutation, InfiniteQuery, or Flow
- Typed
refetch()andoptimisticUpdater()functions that exist at definition (not at use), and are usable anywhere
You can just use the cache, use the cache + its attendants (query, mutation, etc), or use it all in compose land.
DISCLAIMER - Still very rough around the edges. Probably buggy, probably some things that may not work as expected, definitely things missing.