diff --git a/WebSocket.js b/WebSocket.js index c64a4b2..f0b4f9a 100644 --- a/WebSocket.js +++ b/WebSocket.js @@ -243,8 +243,8 @@ Ext.define('Ext.ux.data.proxy.WebSocket', { * The use of this method is discouraged: it's invoked by the store with sync/load operations. * Use api config instead */ - create: function (operation, callback, scope) { - this.runTask(this.getApi().create, operation, callback, scope); + create: function (operation) { + this.runTask(this.getApi().create, operation); }, /** @@ -253,8 +253,8 @@ Ext.define('Ext.ux.data.proxy.WebSocket', { * The use of this method is discouraged: it's invoked by the store with sync/load operations. * Use api config instead */ - read: function (operation, callback, scope) { - this.runTask(this.getApi().read, operation, callback, scope); + read: function (operation) { + this.runTask(this.getApi().read, operation); }, /** @@ -263,18 +263,18 @@ Ext.define('Ext.ux.data.proxy.WebSocket', { * The use of this method is discouraged: it's invoked by the store with sync/load operations. * Use api config instead */ - update: function (operation, callback, scope) { - this.runTask(this.getApi().update, operation, callback, scope); + update: function (operation) { + this.runTask(this.getApi().update, operation); }, /** - * @method destroy + * @method erase * Starts a new DESTROY operation (pull) * The use of this method is discouraged: it's invoked by the store with sync/load operations. * Use api config instead */ - destroy: function (operation, callback, scope) { - this.runTask(this.getApi().destroy, operation, callback, scope); + erase: function (operation) { + this.runTask(this.getApi().destroy, operation); }, /** @@ -282,19 +282,15 @@ Ext.define('Ext.ux.data.proxy.WebSocket', { * Starts a new operation (pull) * @private */ - runTask: function (action, operation, callback, scope) { + runTask: function (action, operation) { var me = this , data = {} , ws = me.getWebsocket() , i = 0; - scope = scope || me; - // Callbacks store me.callbacks[action] = { - operation: operation, - callback: callback, - scope: scope + operation: operation }; // Treats 'read' as a string event, with no data inside @@ -356,7 +352,7 @@ Ext.define('Ext.ux.data.proxy.WebSocket', { resultSet = me.getReader().read(data); // Server push case: the store is get up-to-date with the incoming data - if (Ext.isEmpty(me.callbacks[event])) { + if (!me.callbacks[event]) { var store = Ext.StoreManager.lookup(me.getStoreId()); if (typeof store === 'undefined') { @@ -366,7 +362,7 @@ Ext.define('Ext.ux.data.proxy.WebSocket', { if (action === 'update') { for (var i = 0; i < resultSet.records.length; i++) { - var record = store.getById(resultSet.records[i].internalId); + var record = store.getById(resultSet.records[i].getId()); if (record) { record.set(resultSet.records[i].data); @@ -376,7 +372,11 @@ Ext.define('Ext.ux.data.proxy.WebSocket', { store.commitChanges(); } else if (action === 'destroy') { - store.remove(resultSet.records); + Ext.each(resultSet.records, function(record) { + store.remove(record); + }); + + store.commitChanges(); } else { store.loadData(resultSet.records, true); @@ -385,20 +385,15 @@ Ext.define('Ext.ux.data.proxy.WebSocket', { } // Client request case: a callback function (operation) has to be called else { - var fun = me.callbacks[event] , - opt = fun.operation , + var opt = me.callbacks[event].operation , records = opt.records || data; delete me.callbacks[event]; if (typeof opt.setResultSet === 'function') opt.setResultSet(resultSet); else opt.resultSet = resultSet; - opt.scope = fun.scope; - - opt.setCompleted(); - opt.setSuccessful(); - fun.callback.apply(fun.scope, [opt]); + opt.setSuccessful(true); } } }); diff --git a/bower.json b/bower.json index b046efd..15db49d 100644 --- a/bower.json +++ b/bower.json @@ -31,6 +31,6 @@ "Gruntfile.js" ], "dependencies": { - "ext.ux.websocket": "~0.0.4" + "ext.ux.websocket": "~1.0.0" } } diff --git a/demo/demo.js b/demo/demo.js index 4b6033a..0bf3e25 100644 --- a/demo/demo.js +++ b/demo/demo.js @@ -18,7 +18,11 @@ Ext.onReady(function () { url: 'ws://localhost:9001', reader: { type: 'json', - root: 'user' + rootProperty: 'data' + }, + writer: { + type: 'json', + writeAllFields: true } } }); @@ -41,9 +45,14 @@ Ext.onReady(function () { clicksToEdit: 1 })], - columns: [{ + columns: [ + /*{ + // rownumberer doesn't work in 5.0.0: + // EXTJS-13759 Rownumberer/Action Column causes error when updating row. + // Fixed in Ext JS 5.0.1. xtype: 'rownumberer' - } , { + } , */ + { text: 'ID', dataIndex: 'id', hidden: true @@ -137,7 +146,7 @@ Ext.onReady(function () { var treeStore = Ext.create('Ext.data.TreeStore', { storeId: 'myTreeStore', - autoLoad: true, + autoLoad: false, model: 'TreeModel', proxy: { type: 'websocket', @@ -151,7 +160,7 @@ Ext.onReady(function () { }, reader: { type: 'json', - root: 'children' + rootProperty: 'data' } }, root: { diff --git a/demo/index.html b/demo/index.html index 7439fe5..8067c1f 100644 --- a/demo/index.html +++ b/demo/index.html @@ -3,8 +3,11 @@