I am developing apps using Titanium and trying to implement the CommonJS approach. I like the modular setup, but I am wondering how best to deal with things like a shopping cart: temporary, user-created data that needs to last through the lifetime of the app.
I can see three approaches: 1. Create a special module for such a Cart. It will be created the first time it's require()d, and you can access the cart in its current state from any other module by require()ing it from those modules.
Pass a quasi global Cart object to every module that needs it. This is in breach of the letter and the spirit of CommonJS.
Store the Cart in local memory using Ti.App.Properties. This way, the cart is retained even when the user quits the app.
Any thoughts on what would be best?