Architecture: local state on the server and global state on the client?

Frontend and Backend are not equal. One Backend typically serves many users concurrently or even parallel. A Frontend is rarely used by multiple users at once. Frontend also typically deals with way less data than the Backend.

re-frame also typically only deals with one “global” database, which you can compare to your backend SQL database if you like. There are many other components in the backend that you don’t typically see on the Frontend either (eg. HTTP servers).

You may also want to run multiple instances of the same component on the backend (eg. when dealing with 2 different databases) and that is something where re-frame completely breaks. You can see this in action in re-frame-10x where it can’t just spin up a secondary instance and instead has to bundle its own re-namespaced version of re-frame as it would otherwise clash with your app database.

IMHO you should avoid global state whenever and wherever you can. You can get away with it until you can’t. Frontend typically runs in its own isolated world where you can get much further until you do things like re-frame-10x where it becomes apparent why you maybe shouldn’t do it.

3 Likes