reactpy icon indicating copy to clipboard operation
reactpy copied to clipboard

Create `use_cookie` and `use_indexed_db` Hooks

Open Archmonger opened this issue 2 years ago • 2 comments
trafficstars

Current Situation

Currently, there is no convenient way of storing/retrieving purely client sided data.

Proposed Actions

After we migrate use_query to core, it makes a lot of sense to add a use_cookie hook and use_indexed_db hook.

This might require expanding the IDOM framework to allow hooks to execute JavaScript. So perhaps these hooks are reliant on a use_script hook?

The use_script hook may mean we want to create a FIFO "script processor" on the client side, and then have some method of reporting them back to the server (perhaps this is related?).

Archmonger avatar Dec 20 '22 10:12 Archmonger

This seems to describe a need for third party libraries to subscribe to, and send messages over, the websocket both on the server and the client. This simply isn't possible now and would require a rewrite of the messaging protocol the server and client use now (of which there really isn't one). I mention a similar need briefly in this comment.

While defining scripts in the form of a hook is probably more convenient and React-like. I think you can probably get away with using the script element since it will re-execute if the script source changes. So long as you aren't saving any auth information you should be fine (see #828 for when you shouldn't set cookies with auth info via JS).

rmorshea avatar Dec 20 '22 18:12 rmorshea

the script element is definitely not appropriate for complex tasks such as read/write/modify the client side indexed_db.

Archmonger avatar Dec 20 '22 21:12 Archmonger

Closing this in favor of #894

Archmonger avatar Feb 23 '24 09:02 Archmonger