1. #1
    Touch Premium Member
    Join Date
    Sep 2011
    Posts
    47
    Vote Rating
    1
    Answers
    1
    ruslan.talpa is on a distinguished road

      0  

    Default Answered: Ext.Direct not combining requests

    Answered: Ext.Direct not combining requests


    I have a store with the proxy setup like this:

    Code:
    proxy: {
            type: 'direct',
            api: {
                create  : Test.Projects.create,
                read    : Test.Projects.read,
                update  : Test.Projects.update,
                destroy : Test.Projects.destroy
            }
        }
    and the remoting api like this:
    Code:
    Ext.ns("Test.app"); 
    Test.app.REMOTING_API = {
        "url":"php\/router.php",
        "type":"remoting",
        "enableBuffer":5000,
        "actions":{
            "Projects":[
                {"name":"create","len":1},
                {"name":"read","len":1},
                {"name":"update","len":1},
                {"name":"delete","params":null}
            ]},
        "namespace":"Test"
    };
    However when i do something like:

    Code:
    store.add( {name: 'Added Project from main_store'} );
    store.getAt(0).set('name', 'Project 1 updated');
    store.sync();
    the add and update requests are not sent together but separately, 5s apart?

    Any idea what am i missing?

    Thank you

  2. I think the problem is that i am using Ext.data.Store in combination with a direct proxy.
    There is a special class called Ext.data.DirectStore that i think should be used for this store

  3. #2
    Touch Premium Member
    Join Date
    Sep 2011
    Posts
    47
    Vote Rating
    1
    Answers
    1
    ruslan.talpa is on a distinguished road

      0  

    Default


    I think the problem is that i am using Ext.data.Store in combination with a direct proxy.
    There is a special class called Ext.data.DirectStore that i think should be used for this store

  4. #3
    Touch Premium Member
    Join Date
    Sep 2011
    Posts
    47
    Vote Rating
    1
    Answers
    1
    ruslan.talpa is on a distinguished road

      0  

    Default


    Looked at DirectStore and there is nothing there to suggest that it would combine requests so using DirectStore does not solve the original issue

  5. #4
    Touch Premium Member
    Join Date
    Sep 2011
    Posts
    47
    Vote Rating
    1
    Answers
    1
    ruslan.talpa is on a distinguished road

      0  

    Default


    The issue is rooted deep in the code

    When you do .sync() on a store, it creates a Ext.data.Batch object to which it adds Ext.data.Operation objects and they are executed in "synchronous" mode.

    Ext.data.Operation object have a setting called synchronous to which (in theory) the batch object should look and decide if to wait for the current operation to be executed before running the next one, but this setting is ignored.

    In conclusion, to be able to send create/update/delete requests grouped together with Ext.Direct two things need to happen

    1) fix Ext.data.Batch to obey "synchronous" setting of a operation
    3) have a setting on the (server) store telling it to batch the operation in synchronous/asynchronous mode