My app view model is growing very large. How do I properly split it up into files and namespaces? Do I create a second namespace object and have the view model be passed in as a parameter?
var BALL = {};
BALL.roll = function(avm) { // function code };
My personal preference is not to split up my
applyBindingscalls and instead work with a single global namespace branch off of this.My reasoning is that for multiple bindings to work correctly and not conflict you need to be very careful your selected target dom elements do not change. Unfortunately the markup has a nasty habit of changing over time which can get you in trouble with your viewModels later on.
My general approach which i’ve used on a very large KO project has been
myappSome namespace code I’ve recently been using
So in your myapp.navigation file you would have
This is just shorthand for using a self invoking function to pass in a manually constructed namespace. It gives you a private closure and you are free to use multiple Namespace calls with the same namespace in different js file.
Your applyBindings call can now always be
Hope this helps.