eGovPDX / Council-Agenda-App

5 stars 0 forks source link

dataStore() move to app().get() and app().store() #37

Open OscarGodson opened 13 years ago

OscarGodson commented 13 years ago

Right now I'm setting data that i need to access frequently via these dataStore() objects. This isn't very clean and no clear docs on what is and isn't stored.

I think there needs to be two types of data retrieval:

app().get()
This would allow for some predetermined parameters which would be [method]-[type], for example previous-session or active-item.

Methods:

Types:

This would either return undefined if it didn't exist, or the ID of the corresponding type. These should be stored and updated behind the scenes so that no AJAX request would need to take place and no need for a callback.

//so you can do: 
var lastItem = app().get('last-item');

//rather than:
app().get('last-item',function(item){
  var lastItem = item; 
});

app().store()
This is much more flexible and is sort of like localStorage (in fact, it very well could be behind the scenes). It'd work like:

//Store:
app().store('text-size','12px');

//Get:
app().store('text-size');

//Update
app().store('text-size','14px');

//Remove
app().store('text-size',-1);

Open to suggestions on any of this, but this will be very helpful in the future. dataStore() has already caused issues for @earenson and me when I was trying to check for the last item and broke a personal rule of mine not to use the DOM as a means of checking/storing data.