Title: Add client-side sorting optimization for live query subscriptions · Issue #84 · base44/javascript-sdk · GitHub
Open Graph Title: Add client-side sorting optimization for live query subscriptions · Issue #84 · base44/javascript-sdk
X Title: Add client-side sorting optimization for live query subscriptions · Issue #84 · base44/javascript-sdk
Description: Summary Implement client-side sorting mechanism to prevent unnecessary server refetches when entities are updated in live query subscriptions. Background When using watch() subscriptions without limit or skip clauses, the client can opti...
Open Graph Description: Summary Implement client-side sorting mechanism to prevent unnecessary server refetches when entities are updated in live query subscriptions. Background When using watch() subscriptions without li...
X Description: Summary Implement client-side sorting mechanism to prevent unnecessary server refetches when entities are updated in live query subscriptions. Background When using watch() subscriptions without li...
Opengraph URL: https://github.com/base44/javascript-sdk/issues/84
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add client-side sorting optimization for live query subscriptions","articleBody":"## Summary\nImplement client-side sorting mechanism to prevent unnecessary server refetches when entities are updated in live query subscriptions.\n\n## Background\nWhen using `watch()` subscriptions without `limit` or `skip` clauses, the client can optimize updates by:\n1. Updating the modified entity in the local list\n2. Re-sorting the list client-side\n\nThis avoids the \"sliding window\" problem and reduces server load.\n\n## Proposed Implementation\n\nWhen a snapshot update is received:\n1. If the subscription has no `limit`/`skip` options:\n - For `modified`: Update the entity in place and re-sort\n - For `added`: Insert the entity and re-sort\n - For `removed`: Remove the entity from the list\n2. If the subscription has `limit`/`skip`:\n - Request a full refetch from the server (sliding window case)\n\n## Technical Details\n\n### Sort Parsing\nThe SDK already uses `--` prefix for descending sort (e.g., `--price` for descending by price). Implement a sort comparator that:\n- Parses the sort string\n- Handles ascending/descending\n- Supports nested field paths\n\n### Files to modify:\n- `src/modules/entities.ts` - Add sorting logic in watch handler\n- `src/utils/common.ts` - Add sort utility function\n\n## Considerations\n- Document that `limit`/`skip` subscriptions will trigger full refetches\n- Consider recommending filter-only subscriptions in docs\n- Maintain consistency with server-side sort behavior\n\n## Related\n- Depends on #83 (watch() method implementation)","author":{"url":"https://github.com/guyofeck","@type":"Person","name":"guyofeck"},"datePublished":"2026-01-22T19:48:51.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/84/javascript-sdk/issues/84"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:313e585b-afcb-959f-0369-40077d7428a8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D29E:34A963:A91943:E2028D:6A4C5283 |
| html-safe-nonce | 8c86b99ad0985b175071d2f56dca47e5af25f9d7926ec27441b138e4da2b7d20 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMjlFOjM0QTk2MzpBOTE5NDM6RTIwMjhEOjZBNEM1MjgzIiwidmlzaXRvcl9pZCI6IjcyNjMyOTc4NDExOTUxNDM4MTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 7cb53fafc997e4f0de06c1e19c395674a0da6c2a7ace61ddd337045b273e5f29 |
| hovercard-subject-tag | issue:3844490137 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/base44/javascript-sdk/84/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fc1569827b41ea2b27d5e9d20bf5bd9924dd0a1316efbc43066fbfe0803af8d7/base44/javascript-sdk/issues/84 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fc1569827b41ea2b27d5e9d20bf5bd9924dd0a1316efbc43066fbfe0803af8d7/base44/javascript-sdk/issues/84 |
| og:image:alt | Summary Implement client-side sorting mechanism to prevent unnecessary server refetches when entities are updated in live query subscriptions. Background When using watch() subscriptions without li... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | guyofeck |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3d11bb817438277de2a940854450e83a7d32b6aeb5014e9e6b00a6423900251c |
| turbo-cache-control | no-preview |
| go-import | github.com/base44/javascript-sdk git https://github.com/base44/javascript-sdk.git |
| octolytics-dimension-user_id | 234699998 |
| octolytics-dimension-user_login | base44 |
| octolytics-dimension-repository_id | 939374418 |
| octolytics-dimension-repository_nwo | base44/javascript-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 939374418 |
| octolytics-dimension-repository_network_root_nwo | base44/javascript-sdk |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 14099438da5379150f15a2892474c7c7e6c0e55e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width