Tuesday, 15 February 2011

jquery - Design pattern for real time data -


I have a stream of real-time incidents in which I'm about to come. I am developing a stream for displaying this stream to a user so that:

  • The user will be able to use one of the attributes present in the data
  • The user will be able to sort the data

    Each state in the stream is associated with a state that can be changed at any point, so I have the value of the last X minutes Of data I have to inquire the server and change the customer-wise accordingly.

    My first attempt was using endorsement. However, it is causing the following problems:

    • When users are saying that, 15th page and a new event are added, then I must remember the page that users And make sure that there is no change in it even if the newly added data does not push things too much, it will affect the status of the list in the list and therefore the user will Finding where moved to the previous event.
    • With a special feature, I have to re-sort incoming data and display it. I'm still facing the same problem as above.

      Is there a design pattern for this conversation? Twitter uses this pattern is great but I am not sure how it will be suited to the circumstances:

      • Where the user can sort the data
      • Where I How do I create a marking query on the page using the back-end database to provide data to the front-end?

        Any suggestions?

        This is the best way to achieve your desired result, like the front sorting is. I will not go deeper into infinite scrolling / endorsement because there are probably better resources, but basically keep track of the previous row (or page) and submit it with your request. Hopefully this can prevent you from implementing other issues.

        On the one hand: Depending on the fact that in real-time, you should look at other ways to get the data in line with the number of repeated calls or WebSockets rather than repeated calls. X minutes

        Response format
          {'status': 'OK', 'last_row_rerieved': 20, 'events': [{'html': " Regular Reaction , 'sort_attr_1': 10, ...}}}   

        front-end
          / Maintain / maintain a container for each call result myevents = []; $ .post (..., function (response) {var data = $ .parseJSON (response); var events = data.events; for (var I = 0; i & lt; events.length; i ++) {// save each event myevents.push (events [i]);} displayEvents ();}); // when customer sorting function myevents.sort (Function (a, b) {return a.sort_attr_1 - b.sort_attr_2;}) with a Try to do bit; DisplayEvents (); Display DisplayEvents () {// loop through myupents and display them, though you are doing this}    

No comments:

Post a Comment