cheatcode / joystick

A full-stack JavaScript framework for building stable, easy-to-maintain apps and websites.
https://cheatcode.co/joystick
Other
209 stars 11 forks source link

Add joystick.globalState backed by cache #369

Closed rglover closed 8 months ago

rglover commented 9 months ago

This came to mind in reference to how Cache currently works. It does the trick, but, how you load/reference a cache matters (you can get multiple instances of the same cache in memory, effectively defeating their purpose).

For the majority of use cases, having a single global store in memory makes sense. The proposal would be to have two options:

  1. Use the globalState cache (provided for you by Joystick as a default).
  2. Create your own cache using Cache just like you would today.

The 2nd option would be reserved for rare use cases where you couldn't/shouldn't mix data in a single store.