State in `main.js`, callback instead of singleton

Been reading a lot about drawbacks of the singleton pattern, so want
to try this alternative.