title: Am I overusing the Knockout mapping plugin by always using it to do my viewmodel?
body: <p>I'm still learning the proper usage of Knockout and I've found myself quickly getting away from ever typing <code>ko.observable</code> when setting up my viewmodel and instead just defining an object literal and passing it through the mapping plugin with something like </p>
  
  <pre><code>var viewModel = ko.mapping.fromJS(data);
  </code></pre>
  
  <p>or at the very least, something along the lines of stuffing all of my data into an attribute on the viewModel like so</p>
  
  <pre><code>var viewModel = { 
      ... events etc ... , 
      "data": ko.mapping.fromJS(data)
  }
  </code></pre>
  
  <p>To be honest, the main reason I've been doing this is to get around having to type <code>ko.observable</code> and <code>ko.observableArray</code> repetitively.  I'm just trying to figure out if this is a good approach and if there are any downsides to dropping the specific <code>var x = ko.observable()</code> declaration all together.  Also, I'm doing this all on load, not in response to any ajax call etc, which from what I can tell, is what the mapping plugin was designed for.</p>
  
  <p>In your work with knockout, do you still declare the observables manually, one by one, or have you gone with the mapping.fromJS method that I use?  Are there any specific downsides to using the mapping plugin so frequently like this? </p>
  
  <p>Edit:</p>
  
  <h2>Specific Example</h2>
  
  <p><a href="http://blog.stevensanderson.com/2010/07/12/editing-a-variable-length-list-knockout-style/">In this article</a>, Steve sets up his viewModel by doing</p>
  
  <pre><code>var initialData = [ { ... } , { ... } ]; // json from the serializer
  var viewModel = {
      gifts : ko.observableArray(initialData)
  };
  </code></pre>
  
  <p>Normally, I'd just use <code>ko.mapping.fromJS</code> for this situation as well, specifically to make sure the objects within the array are turned into observables as well.  Looking at what he did, my approach seems like its overkill and adds a bit of unnecessary overhead.</p>