ExtJS 5 : get a store from anywhere in your app

In the app I’m working on, I have multiple stores, and I need to get an access to any of them from anywhere.

There are multiple approaches: store (!) the Stores’list in a global variable or in an App variable, …

In fact, there is a much more simple way. When you declare your store, setup a “storeId” parameter.

Ext.create('Ext.data.Store',
{
  model: 'My.Model',
  storeId: 'my-model-store'
  [...]
}

Then, to easily access this store from anywhere:

var store = Ext.data.StoreManager.lookup('my-model-store');

Let’s be honest : it is nothing more than a global variable and you can achieve the same easily; anyway, it conveniently rocks!