feat: auth & admin
This commit is contained in:
@@ -12,13 +12,11 @@ When fetching nested data in parallel, chain dependent fetches within each item'
|
||||
**Incorrect (a single slow item blocks all nested fetches):**
|
||||
|
||||
```tsx
|
||||
const chats = await Promise.all(
|
||||
chatIds.map(id => getChat(id))
|
||||
)
|
||||
const chats = await Promise.all(chatIds.map((id) => getChat(id)));
|
||||
|
||||
const chatAuthors = await Promise.all(
|
||||
chats.map(chat => getUser(chat.author))
|
||||
)
|
||||
chats.map((chat) => getUser(chat.author)),
|
||||
);
|
||||
```
|
||||
|
||||
If one `getChat(id)` out of 100 is extremely slow, the authors of the other 99 chats can't start loading even though their data is ready.
|
||||
@@ -27,8 +25,8 @@ If one `getChat(id)` out of 100 is extremely slow, the authors of the other 99 c
|
||||
|
||||
```tsx
|
||||
const chatAuthors = await Promise.all(
|
||||
chatIds.map(id => getChat(id).then(chat => getUser(chat.author)))
|
||||
)
|
||||
chatIds.map((id) => getChat(id).then((chat) => getUser(chat.author))),
|
||||
);
|
||||
```
|
||||
|
||||
Each item independently chains `getChat` → `getUser`, so a slow chat doesn't block author fetches for the others.
|
||||
|
||||
Reference in New Issue
Block a user