diff --git a/README.md b/README.md index b4f66116..0ce120b0 100644 --- a/README.md +++ b/README.md @@ -159,10 +159,15 @@ space.members.subscribe('remove', (memberRemoved) => { console.log(memberRemoved); }); -// Subscribe to member profile update events only -space.members.subscribe('update', (memberProfileUpdated) => { +// Subscribe to profile updates on members only +space.members.subscribe('updateProfile', (memberProfileUpdated) => { console.log(memberProfileUpdated); }); + +// Subscribe to all updates to members +space.members.subscribe('update', (memberUpdate) => { + console.log(memberUpdate); +}); ``` The following is an example event payload received by subscribers when member updates occur in a space: diff --git a/docs/class-definitions.md b/docs/class-definitions.md index 993ab045..8b713edf 100644 --- a/docs/class-definitions.md +++ b/docs/class-definitions.md @@ -205,15 +205,25 @@ Listen to member events for the space. See [EventEmitter](/docs/usage.md#event-e The argument supplied to the callback is a [SpaceMember](#spacemember) object representing the member removed from the space. -- ##### **update** +- ##### **updateProfile** Listen to profile update events of members. ```ts - space.members.subscribe('update', (member: SpaceMember) => {}) + space.members.subscribe('updateProfile', (member: SpaceMember) => {}) ``` The argument supplied to the callback is a [SpaceMember](#spacemember) object representing the member entering the space. +- ##### **update** + + Listen to `enter`, `leave`, `updateProfile` and `remove` events. + + ```ts + space.members.subscribe('update', (member: SpaceMember) => {}) + ``` + + The argument supplied to the callback is a [SpaceMember](#spacemember) object representing the member affected by the change. + #### unsubscribe() diff --git a/docs/usage.md b/docs/usage.md index 82b69a4d..110a6688 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -165,7 +165,9 @@ See [SpaceMember](/docs/class-definitions.md#spacemember) for details on propert ### Member events -Subscribe to either all the member events or specifically to `enter`, `leave`, `remove` or `update` events related to members in a space. +Subscribe to either all the member events or specifically to `enter`, `leave`, `remove` or `updateProfile` events related to members in a space. + +To listen to all events pass either no event name or `update`: ```ts space.members.subscribe((memberUpdate) => { @@ -173,6 +175,12 @@ space.members.subscribe((memberUpdate) => { }); ``` +```ts +space.members.subscribe('update', (memberUpdate) => { + console.log(memberUpdate); +}); +``` + #### enter Emitted when a member enters a space. Called with the member entering the space. @@ -203,16 +211,18 @@ space.members.subscribe('remove', (memberRemoved) => { }); ``` -#### update +#### updateProfile Emitted when a member updates their `profileData` via `space.updateProfileData()`: ```ts -space.members.subscribe('update', (memberProfileUpdated) => { +space.members.subscribe('updateProfile', (memberProfileUpdated) => { console.log(memberProfileUpdated); }); ``` + + To stop listening to member events, users can call the `space.members.unsubscribe()` method. See [Event emitters](#event-emitters) for options and usage.