Skip to content

JSON Changes Do Not Persist #149

Open
@Unknown025

Description

@Unknown025

Hello there!

I've been trying to figure out a very simple problem, and have come to a solution that doesn't sit well with me, so I wanted to reach out and double check.

I have some functionality that requires reading from a key, making changes to the object retrieved from that key, and writing those changes back to the original key. The problem is that the changes I make to that key don't get saved. I've verified that the changes don't just vanish into thin air, via use of Electron/Chrome's debugger, and through console statements. The original value of the retrieved key gets written back to the file. Here's a relevant example: Gist

The only meaningful solution I've found so far is to stringify the result of storage.get() and parse it back to JSON, which doesn't seem like a good solution. Writing entirely different objects, without calling storage.get(), works as expected. Anything I'm doing wrong? I'm using Electron 10 (though I updated from Electron 6, which had the same problem) combined with React.
I'm not an expert on JavaScript or Electron, so I'm hoping that I made a mistake somewhere. Everything is performed on the renderer, but I briefly tried using the backend process, to no avail.

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions