Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dojo dgrid + WebSocket issues #1339

Open
fuje opened this issue Jan 9, 2017 · 2 comments
Open

Dojo dgrid + WebSocket issues #1339

fuje opened this issue Jan 9, 2017 · 2 comments

Comments

@fuje
Copy link

fuje commented Jan 9, 2017

I've already posted this on Stack Overflow (link here), but since I got no answers, I decided to post it here. Sorry if this is not a good place for that

I've been struggling for a while with this issue. In my application, I'm using an OnDemandGrid, backed by a Request + Trackable dstore, to display my data to the user.

The server sends notifications to the client via websocket to add new entries to the grid. To add the new entries to the grid, the store is emiting an 'add' event, something like the following piece of code:

function _emitAddEvent(store, entity) {
    store.emit('add', {
        target: entity,
        id: entity.id
    });
}

Until here, it's all good. The application receives the new entry from the server to be added to the grid, and adds it (without refreshing the grid). The problem is if there are too many notifications being sent by the server during a small time interval. The store emits all the events to the dgrid, but the grid tooks some time to render all the rows. Because there are too many entries to be added, the application goes unresponsive. If the server stops sending data to the client, after some time the application recovers and render all the rows correctly. Now comes the second (but minor) issue.

The second issue is that, after the grid renders all the new rows, it does not destroy the rows that are too far. I've set the farOffRemoval attribute, but it seems to only handle cases where a scroll happens and new data is requested to the server. I would like to know if there is a workaround, that does not rely on scroll, to destroy nodes that are too distant from the user current position on the grid.

Thanks in advance.

@dylans
Copy link
Member

dylans commented Jan 10, 2017

I was going to suggest using throttling for the first part, which it sounds like you've done. As far as triggering the removal, you're right in that a scroll event usually triggers that. I would think you could emit a 0px or 1px scroll event on the dgrid instance? Otherwise I think you might need to reimplement something like https://github.com/SitePen/dgrid/blob/b1603c6c0359896060cfe02cf0dd250cf1ce9239/OnDemandList.js#L461 . Another option is to periodically refresh which might be sufficiently fast as long as it works against cached data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
@dylans @fuje and others