livekit / components-js

Official open source React components and examples for building with LiveKit.
https://livekit.io
Apache License 2.0
157 stars 72 forks source link

Add overload for kind + identity in `useRemoteParticipant` hook #893

Closed lukasIO closed 3 months ago

lukasIO commented 3 months ago

Simplifies agent usecases

const agent = useRemoteParticipant({ kind: ParticipantKind.Agent });
changeset-bot[bot] commented 3 months ago

🦋 Changeset detected

Latest commit: b311b4424eb8441843eebdcb765dbd6d035b7d80

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages | Name | Type | | --------------------------------- | ----- | | @livekit/components-core | Patch | | @livekit/components-react | Patch | | @livekit/component-example-next | Patch | | @livekit/components-js-docs | Patch | | @livekit/component-docs-storybook | Patch | | @livekit/components-docs-gen | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

github-actions[bot] commented 3 months ago

size-limit report 📦

Path Size
LiveKitRoom only 1.87 KB (0%)
LiveKitRoom with VideoConference 28.24 KB (0%)
All exports 33.71 KB (+0.21% 🔺)
davidzhao commented 3 months ago

Thinking out loud, should we instead do this?

useParticipant(kind: ParticipantKind.Agent, name: "myagent", identity: "blah")

that way, we could provide a general framework of returning the first participant matching these key filters

lukasIO commented 3 months ago

Today there's useRemoteParticipant(identity) already.

I could imagine an overload for that hook with something like

useRemoteParticipant( { identity?: string; kind?: ParticipantKind })

What usecase do you imagine with name additionally being part of the selector/filter?

davidzhao commented 3 months ago

Today there's useRemoteParticipant(identity) already.

I could imagine an overload for that hook with something like

useRemoteParticipant( { identity?: string; kind?: ParticipantKind })

What usecase do you imagine with name additionally being part of the selector/filter?

great. I like that.. just thinking we could let user specify additional filters. Agreed name shouldn't be one today, I'm not quite sure why I put that in.

lukasIO commented 3 months ago

Makes sense, updated the PR to add an overload for useRemoteParticipant instead