javascript - Backbone.js Calculator App Architechture (Singleton Model) -
i'm looking guidance on architecture app i'm building in backbone.
it's multi-page app calculates data based on initial data-set. initial data-set country specific , getting pulled in json file.
when app fires up, data-set used defaults: in main backbone.model. these defaults have processed/calculated , set additional model attributes. these attribute represent app state. can overridden ui. recap, i'm using singleton backbone.model store initial data, i'm building rest of data on models initialize method.
i recalculate data-set attributes on model.change event. fires models custom method updateattributes() recalculates data. seems me it's pretty inefficient because i'm calculating attributes, first in initialize method, , again in updateattributes method.
after values processed data set complete , can applied app templates. tricky part of calculated data in set editable ui. once these default attributes edited ui don't want updateattributes method recalculate values because no longer default data, userdefined data.
i'm not quite sure go point, i'm thinking of setting attributes on (rapidly expanding) model such attributenamesetfromui: true, , having if() statements in updateattributes() method check these , skip on part of calculation if default isn't necessary.
i'm not sure if large singleton model way go, seems work enough.
if has tips scenario awesome. i'm new backbone, finding quite challenging!
Comments
Post a Comment