cerebral/overmind

Holding objects in state without proxying them

gsimone opened this issue · 2 comments

Hey, we are moving a big codebase to overmind and I'm loving it <3
I wanted to ask if there's a way to hold a reference without actually proxying it, since it would be convenient to be able to transport objects around without actually listening to mutations. My temp solution is to have them in an effect.

Valtio - another proxy-based state lib - implemented a ref helper to opt out of proxying, think it would be possible to have something like this? I'd be up for contributing it, if it's something you are interested in adding! Otherwise, pointers as to where I could patch or otherwise add the feature in userland, would be appreciated.

Thank you so much for the awesome lib!

Valtio - https://github.com/pmndrs/valtio#holding-objects-in-state-without-tracking-them

@gsimone did you further invest in this? I also would be interested in such feature!

My solution to this when I needed it was to store a function which returns that object instead storing the object directly. So:
instead

const store = {
  coolItem
}

do

const store = {
    getCoolItem: () => {return coolItem}
}