transport.push Function

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).

Parameters

callbacks Object

An object containing callbacks for notifying the data source of push notifications.

callbacks.pushCreate Function

A function that should be invoked to notify the data source about newly created data items that are pushed from the server. Accepts a single argument - the object pushed from the server which should follow the schema.data configuration.

callbacks.pushDestroy Function

A function that should be invoked to notify the data source about destroyed data items that are pushed from the server. Accepts a single argument - the object pushed from the server which should follow the schema.data configuration.

callbacks.pushUpdate Function

A function that should be invoked to notify the data source about updated data items that are pushed from the server. Accepts a single argument - the object pushed from the server which should follow the schema.data configuration.

Example

<script src="https://ajax.aspnetcdn.com/ajax/signalr/jquery.signalr-1.1.3.min.js"></script>
<script>
var hubUrl = "https://demos.telerik.com/kendo-ui/service/signalr/hubs";
var connection = $.hubConnection(hubUrl, { useDefaultPath: false});
var hub = connection.createHubProxy("productHub");
var hubStart = connection.start({ jsonp: true });
var dataSource = new kendo.data.DataSource({
transport: {
  push: function(callbacks) {
    hub.on("create", function(result) {
/* The result can be observed in the DevTools(F12) console of the browser. */
      console.log("push create");
      callbacks.pushCreate(result);
    });
    hub.on("update", function(result) {
/* The result can be observed in the DevTools(F12) console of the browser. */
      console.log("push update");
      callbacks.pushUpdate(result);
    });
    hub.on("destroy", function(result) {
/* The result can be observed in the DevTools(F12) console of the browser. */
      console.log("push destroy");
      callbacks.pushDestroy(result);
    });
  }
},
schema: {
  model: {
    id: "ID",
    fields: {
      "ID": { editable: false },
      "CreatedAt": { type: "date" },
      "UnitPrice": { type: "number" }
    }
  }
}
});
</script>
In this article