Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominik Piatek committed Sep 4, 2023
1 parent 0bb159a commit 92b0cc5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 12 additions & 2 deletions docs/class-definitions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
16 changes: 13 additions & 3 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,22 @@ 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) => {
console.log(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.
Expand Down Expand Up @@ -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.


Expand Down

0 comments on commit 92b0cc5

Please sign in to comment.