title: Single or multiple store instances on different components?
body: <p>This is more like a best practice/advice that i am asking here, because i already found a solution to my problem, but i dont know:</p>
  
  <ul>
  <li>if the "problem" should be solved;</li>
  <li>if the solution is the best one.</li>
  </ul>
  
  <p>Wait, let's go back a little to the issue. I have a book manager application, and it uses, among others, two kind of objects: <code>Book</code> and <code>Author</code>. As you can imagine, every <code>Book</code> has an <code>Author</code>, so, i need:</p>
  
  <ul>
  <li>a manager to define the authors (i have used a grid);</li>
  <li>a way to select the author for a book (i have used a combo box);</li>
  </ul>
  
  <p>In ExtJS, this involved an <code>Ext.grid.Panel</code> and a <code>Ext.form.field.ComboBox</code>  .
  I have used the same store (<code>AuthorStore</code>) on each widget, since my <code>Author</code> class is very simple (having only <code>id</code> and <code>authorName</code> as fields). Initially, i have used <code>autoLoad:true</code> property for the store, but, as i discovered <a href="https://stackoverflow.com/questions/19588780/extjs-store-with-autoload-true-should-not-load-on-application-launch">here</a>, there is a better way to do it: to load the store on <code>render</code> or <code>afterrender</code> events for the required component. I totally agree with this. </p>
  
  <p>After that, i've noticed that both the grid and the combo had different store instances (each loading its data). This seemed strange to me, since, basically, both store instances hold exactly the same data. At this point, i wanted somehow to share the same store instance for both components. I did something like:</p>
  
  <ul>
  <li><p>Defined a function that returns a single store instance:</p>
  
  <pre><code>function getAuthorStore(){
       return Ext.StoreMgr.lookup('authorStore') || Ext.create('BM.store.AuthorStore');
  }
  </code></pre></li>
  <li><p>Changed grid's store property from <code>store: 'AuthorStore',</code> to <code>store: getAuthorStore()</code></p></li>
  <li><p>Did the same thing for the combo-box</p></li>
  <li><p>Changed the <code>AuthorStore</code> to declare an additional property and a listener for the <code>load</code> event:</p>
  
  <pre><code>    storeId: 'authorStore',            
      loaded: false,
      listeners: {
          load: function(store, records, success, operation, options) {
              store.loaded = success;
              console.log('store &lt;&lt;' + store.storeId + '&gt;&gt; was fully reloaded');
          }
      }
  </code></pre></li>
  <li><p>Changed to grid's controller store property from <code>store: 'AuthorStore',</code> to <code>store: getAuthorStore()</code>. Also, the <code>render</code> event is added, and the following function is called:</p>
  
  <pre><code>    loadStoreIfRequired: function() {
          var me = this;
          // loads the store only if the 'loaded' custom prop is not set
          if (!me.store.loaded) {
              me.store.load();
          }
      }
  </code></pre></li>
  <li><p>Finally, i did something similar to the combo box (please note the <code>queryMode: 'local'</code> that is used so that the combo's store dont load itself when opening the combo items.</p>
  
  <pre><code>    ....
      queryMode: 'local',
      store: getAuthorStore(),
      listeners: {
          render: function(combo, options) {
              var store = combo.getStore();
              if (!store.loaded) {
                  store.load();
              }
          }
      }
  </code></pre></li>
  </ul>
  
  <p>What i would like to know is the answer to the following questions:</p>
  
  <ol>
  <li>Is the single store instance idea good or bad?</li>
  <li>Let's assume i have some filters on the grid. These filters will cause the combo to display, let's say, less items in the combo,
  since they share the same store? (Therefore, in this case, the store
  should not be shared across multiple widgets).</li>
  <li>If there a better/cleaner solution to this?</li>
  </ol>
  
  <p>Thank you very much for taking your time to read my question. Please share your thoughts, if you have them.</p>