Can you serialize data between program sessions?


For the life of me I can’t figure out how to serialize/deserialize between restarts. Is it possible? Is state only held while is open? Im currently using LocalStorage as a persistent alternative.


There’s a help document on serialization:


That is actually a pretty good method that I have been considering using myself. Chromium allows LocalStorage to be arbitrarily large compared to the chrome browser which only allows a small amount of storage.

The problem I have with Atom’s serialization is that it is per-project, which the docs don’t mention. Several times I wanted to store stuff that is available no matter what project is opened and I had to save it in the user’s home folder, which is not a good solution. LocalStorage can be based on anything by using the proper keys. Also you get to use key/values which Atom doesn’t offer.


I’ve read and implemented the instructions on that doc page. And I can only ever get the state to be passed into activate when “reloading” atom. If I close the program and reopen. Nothing is passed in. Is this by design?


Can you show your code?


It’s all but hooked up but you’ll get the idea.


Where is the serializer MyPackageView defined?


@mark_hanh: This code prints an empty Object when atom is started, {hellow:"world"} when restarted using CTRL+ALT+R and again empty Object when we restart the editor.

module.exports =
    console.log state


It works fine for me, with out without any activation events. Can you show me your package.json file?

Some questions…

  • Are you running Atom on a project folder or just starting from a desktop icon?
  • Versions?
    • Atom
    • OS
  • How did you install Atom?

Try renaming or moving your ~/.atom folder and restarting Atom. Then create a new test project with package generator, put in your code, and remove activation events from your package.json. Restart atom and check the console again.


@mark_hanh: Everything else works perfectly for me, I am on Ubuntu 14.04 using atom v0.176. I think I am having trouble with it because of the per-project limitation.
@danielmahon: as @mark_hanh states atom’s serialization is per project. and I don’t think it’s gonna work for open-last-project because It is the one who tells atom about the opened project.


@mark_hanh I discovered that Serialization store only works when you Start atom in that folder. It doesn’t work when you modify the atom.project.path programmatically. Any ideas?


I don’t know what this means. Can you please explain?


Oh, I typed gramatically, It was a typo, I meant programatically. Like


I just posted an issue on setPaths to atom/atom yesterday. But it was a different problem caused by working serialization.

Back to the topic at hand, I don’t have a clue about your problem. I can’t repeat it on my setup. Sorry.

Edit: Ignore that. I didn’t really try to repeat it with your latest description. I’ll try later.