atharesinc / athares

Expo Web and Native Codebase
0 stars 0 forks source link

Implemented in-memory synchronous storage to run in conjunction with async SecureStorage #41

Closed actuallydan closed 3 years ago

actuallydan commented 3 years ago

Closes #6 Since each Apollo Context request gets the user's token asynchronously on every request, the request can take slightly longer to complete if our async storage solution takes a while to get items.

This implements a solution to get all of our important keys from localforage/secureStore at initialization time, and puts them in a synchronous in-memory Map that can shave off up to ~500 ms on some of the initial requests. All requests now take <1 ms to get this token, but most of them were only taking a 10-100ms anyway so this may not be as robust a change as hoped.

Additionally, this does some query removal by skipping queries if certain values are null and bound to return useless data with the skip property for useQuery.