Comments (5)
Hey @saiprakash2, we've just released a new option that simplifies this. If we take the original code snippet, you can see the before and after in the snippet below, enabled by nextCursor
.
let cursor: string | null = null;
while (true) {
const resp = await client.getRooms({ startingAfter: cursor });
doSomethingWithRooms(resp.data); // current page
if (resp.nextPage === null) {
break; // Done paginating
} else {
// ❌ Before
cursor = resp.nextPage.split("startingAfter=")[1].split("&")[0];
// ✅ After
cursor = resp.nextCursor;
}
}
You need to udpate all your packages to 1.9.7
to see this. Find more information under liveblocks.getRooms
.
from liveblocks.
Are you talking about improving REST api server responses here instead of updating
liveblocks/node
client?
Exactly, it would be nicer to have the data available directly instead of having to parse it out in the node client, which feels like a bit of a hack!
Is REST api code open sourced?
Unfortunately the REST API is not open source.
from liveblocks.
Hii @nvie ,
I have one suggestion here. Can't we do this cursor = resp.nextPage.split("startingAfter=")[1].split("&")[0];
in the api itself so that we can send cursor value in the server responses. In that way they dont' have to do the parsing.
If it is null then no more pagination or if it has value then they can use it to fetch the next set of data.
This might be an easy fix.
Please let me know if it works or I will look into it bit more 🙂.
from liveblocks.
Yep! That’s my preferred approach too. We can let the server send those cursor
and limit
fields back in those responses, right next to the nextPage
field with that value in there.
from liveblocks.
Hi @nvie,
Are you talking about improving REST api server responses here instead of updating liveblocks/node
client?
Is REST api code open sourced?
from liveblocks.
Related Issues (20)
- The `@liveblocks/node` client crashes when secret key is invalid HOT 4
- Problem to fetch data from Liveblocks API when not setting a schema HOT 3
- Delete thread server API
- useDeleteThread HOT 1
- Deleting a room should delete associated threads and comments for GDPR
- `TypeError: storage.get(...).get(...).set is not a function` with useMutation and nested live object HOT 2
- YJS Integration Does not Appear to Fire Awareness `update` Event HOT 1
- Yjs image upload > 500KB raises websocket error with code 1005 HOT 2
- Minor type error in Awareness.states
- React `useThreads` incorrect usage of `useSyncExternalStoreWithSelector` triggers infinite re-renders HOT 1
- Fix to the error: Type `LiveObject<Layer>` does not satisfy the constraint `Lson` HOT 2
- Ensure useSyncExternalStoreWithSelector usage are stable
- Ghost Websocket Connections! HOT 4
- Support comments mention containing `@` HOT 1
- Simplify `liveblocks.config.ts` generics for the common case HOT 1
- The Zustand middleware's `set` cannot safely be nested inside `batch`
- `Storage` type issue in `createRoomContext` in `liveblocks.config.ts` HOT 1
- Type error: Type `Storage` does not satisfy the constraint `LsonObject`. in `liveblocks.config.ts`
- Does `react-native-todo-list` need updating?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from liveblocks.