Effect CommunityEC
Effect Community10mo ago
4 replies
Bilal

Returning Headers from RPC Responses for Out-of-Band Information

I have another question regarding the RPC module - is it possible to return headers from responses as well?

In particular I am trying to find a way to return some information "out of band" from the actual stream. There are many examples where this is quite helpful, particularly when trying to implement pagination. The header for example could be used to signify the next cursor or the amount of remaining elements.

While some of this can be achieved by just pausing and resuming the stream. There's a certain benefit to having that information either way.

For example (a real world example) - I want to show the user who is the member of a specific group. If there are more than 4 users, we simply show an indicator of "+2". Now it would be silly to just fetch every single user, then do that filtering step on the client - if it could be done on the server, but that requires that the client knows what the total amount is. (Of course in theory this could be done via two queries, but essentially you'd be duplicating work for the server here)
Was this page helpful?