Fork me on GitHub
#re-frame
<
2015-12-22
>
gabe14:12:54

Anyone tried using localStorage or sessionStorage w/ re-frame?

mccraigmccraig14:12:12

@gabe: i'm using local storage

gabe14:12:31

@mccraigmccraig: how did you wedge it in there?

gabe14:12:06

did you just make some middleware or a wrapper register function?

gabe14:12:46

I was wanting to use something like

gabe14:12:33

but I think that would require redefining re-frame.db

mccraigmccraig14:12:13

hold on... just looking for the code

mccraigmccraig14:12:18

@gabe: i used alandipert/storage-atom , and read from it in a handler

mccraigmccraig14:12:59

to set values in the app-db

mccraigmccraig14:12:13

or vice-versa, set values in local storage

gabe14:12:57

@pepe: I’ll take a look. thx

gabe14:12:17

@mccraigmccraig: how did you initially wrap app-db?

mccraigmccraig14:12:11

@gabe: what dyu mean by 'wrap app-db' ?

gabe14:12:00

using alandipert.storage-atom/session-storage

mccraigmccraig14:12:58

oh, i'm not doing that - i'm just storing a couple of select bits of info into local-storage

mccraigmccraig14:12:20

i retrieve them at init time, and update them as required

mccraigmccraig14:12:49

if you want to put everything into local storage then i imagine a middleware based approach is easiest since app-db is a reagent atom, not a vanilla atom

gabe14:12:28

i don’t think it should matter as they should have the same interface

gabe14:12:16

i’ll play around w/ it and let you know what i find

gabe14:12:08

you’re right though, it might be easiest to shadow app-db w/ another atom

gabe16:12:12

@mccraigmccraig: that’s what i ended up doing

gabe16:12:57

works great as long as i strip out any components i might have in my app-state before i reset!

gabe16:12:18

thanks again for your help