1. #1
    Sencha User ykey's Avatar
    Join Date
    Mar 2010
    Location
    USA
    Posts
    245
    Vote Rating
    27
    ykey has a spectacular aura about ykey has a spectacular aura about

      0  

    Default Store configured with same LocalStorageProxy config and multiple tabs

    Store configured with same LocalStorageProxy config and multiple tabs


    I want my Store configured with a LocalStorageProxy to automatically listen for the browser's LocalStorage StorageEvent and update itself and fire standard store events. Especially when the LocalStorage data is added from another tab for cross-window communication.

    I experimented with the following but it gets fired multiple times because the LocalStorageProxy stores a lot of entries in the LocalStorage:
    Code:
    window.addEventListener("storage", function() {
    	var store = Ext.getStore('searchstore');
    	if (store) store.load();
    }, false);
    Am I asking too much here? Has anyone else experimented with this?

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,791
    Vote Rating
    833
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Have you looked at the events for a Store? The proxy will get the data from local storage once you load the Store so why listen for the storage event? You don't need it.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User ykey's Avatar
    Join Date
    Mar 2010
    Location
    USA
    Posts
    245
    Vote Rating
    27
    ykey has a spectacular aura about ykey has a spectacular aura about

      0  

    Default


    I will take another look but that event didn't seem to fire when the local storage was updated from another tab.

  4. #4
    Sencha User ykey's Avatar
    Join Date
    Mar 2010
    Location
    USA
    Posts
    245
    Vote Rating
    27
    ykey has a spectacular aura about ykey has a spectacular aura about

      0  

    Default


    I think you are missing the point. I would expect the local storage proxy to have all the features of HTML 5 local storage. What is missing is the cross-window/tab communication of local storage changes.

    I do understand however if this proxy wasn't intended to work this way.

    I have created a simple test case.

    Use case: Load Tab 1 in a tab, Load Tab 2 in a tab, Reload Tab 1, inspect console in Tab 2.
    Result: Tab 2 does not fire a 'datachanged' event even though the local storage was changed by Tab 1.

    Tab 1
    Code:
    Ext.regModel('Search', {
        fields: ['id', 'query'],
    
        proxy: {
            id  : 'searches',
    	type: 'localstorage'				
        }
    });
    		
    // Does not trigger datachanged for stores using 'Search' model in other windows
    var search = Ext.ModelMgr.create({query: 'Query'}, 'Search');
    search.save();
    Tab 2
    Code:
    Ext.regModel('Search', {
        fields: ['id', 'query'],
    
        proxy: {
            id : 'searches',
            type : 'localstorage'				
        }
    });
    			
    var store = new Ext.data.Store({
        model: 'Search',
        storeId: 'searchstore',
        autoLoad: false // This doesnt seem to do anything but trigger datachanged when true
    });
    				
    store.load({
        scope: this,
        callback: function(records, operation, success) {
            console.log(records);
        }
    });
    			
    console.log(store.getCount());
    	
    // Datachanged fires on page load when autoLoad is true but the store doesn't load
    store.on('datachanged', function(store, data) {
        console.log('datachanged:', data);
    });

Similar Threads

  1. Gridfilters: multiple stores, multiple grids, multiple tabs
    By mike2406 in forum Ext 3.x: Help & Discussion
    Replies: 3
    Last Post: 20 Feb 2013, 8:31 AM
  2. Pre-configured Store
    By westy in forum Ext: Discussion
    Replies: 1
    Last Post: 14 Apr 2011, 2:11 AM
  3. Replies: 0
    Last Post: 3 Oct 2008, 10:01 AM
  4. Replies: 1
    Last Post: 14 May 2008, 11:35 PM

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi