I am not clear how exactly the grid-datasource (websocket) demo works. Specifically, i am confused about this code:
push: function(options) {
//Listen to the "message" event fired when the server pushes data
ws.addEventListener("message", function(e) {
var result = JSON.parse(e.data);
//Check what the push type is and invoke the corresponding callback.
if (result.type == "push-update") {
options.pushUpdate(result);
} else if (result.type == "push-destroy") {
options.pushDestroy(result);
} else if (result.type == "push-create") {
options.pushCreate(result);
}
});
},
The documentation says the "The function invoked during transport initialization which sets up push notifications. The data source will call this function only once and provide callbacks which will handle push notifications (data pushed from the server).". So, it seems like the purpose of this push is to set callbacks ? Isn't that what we are doing in the send function ? Before we send any data, we specify callbacks.
Secondly, what is this "options" parameter. As per the documentation its a callback object. But then where are the options.purshCreate(), options.pushUpdate() etc defined ? What are they doing ?