byu-osl / city-issue-tracker

An issue tracker for cities
GNU General Public License v2.0
2 stars 3 forks source link

Javascript Model #5

Closed samsieber closed 10 years ago

samsieber commented 10 years ago

So the javascript communicator looks pretty good.The open311 npm code I found is mostly just handling cases we won't have, like variable server hosts or xml responses. The one thing that it does that's cool is turning the date strings into native javascript date objects. So I'll work that in to our code.

As for the general structure of the JS, I was thinking something along the lines of

Views Controller Model Proxy

Where the model uses the Proxy to update itself and execute actions, while the controller 1) reacts to the model by updating the views and 2) requests actions from the model based off of input views. Then we can swap out the proxy for a fake one that just returns fake data without even talking to the server.

In the mean time, I can stub out the fake proxy and get it returning fake data.

I do have two things that I'm wondering about that may end up being moot:

1) How much should we worry about the library size? For example, jquery.min.js (1.9) is ~90kb and Ractive.min.js is ~110kb. Of course both get cut down quite a bit if we gzip them... The real question is, in terms of getting this site to load quickly, does the size of the js or the cost of the call to get the data make the biggest impact.

2) Can we use promises? It's cool if we don't, but they seem like they make callbacks a lot easier. It's basically being able to chain callbacks easily. See this link: http://www.html5rocks.com/en/tutorials/es6/promises/