You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* <!-- BEGIN WEBSITE DOCUMENTATION (https://github.com/ably/docs/blob/cb5de6a6a40abdcb0d9d5af825928dd62dc1ca64/content/spaces/locations.textile?plain=1#L9-L11) -->
46
-
* The member location feature enables you to track where members are within a space, to see which part of your application they’re interacting with. A location could be the form field they have selected, the cell they’re currently editing in a spreadsheet, or the slide they’re viewing within a slide deck. Multiple members can be present in the same location.
47
-
*
48
-
* Member locations are used to visually display which component other members currently have selected, or are currently active on. Events are emitted whenever a member sets their location, such as when they click on a new cell, or slide. Events are received by members subscribed to location events and the UI component can be highlighted with the active member’s profile data to visually display their location.
75
+
* [Member locations](https://ably.com/docs/spaces/locations) enable you to track where members are within a {@link Space | space}, to see which part of your application they’re interacting with. A location could be the form field they have selected, the cell they’re currently editing in a spreadsheet, or the slide they’re viewing within a slide deck. Multiple members can be present in the same location.
49
76
*
50
-
* <!-- END WEBSITE DOCUMENTATION -->
77
+
* Location events are emitted whenever a member changes their location, such as by clicking on a new cell or slide. This enables UI components to be highlighted with the active member's profile data to visually display their location.
51
78
*
52
-
* <!-- BEGIN WEBSITE DOCUMENTATION (https://github.com/ably/docs/blob/cb5de6a6a40abdcb0d9d5af825928dd62dc1ca64/content/spaces/locations.textile?plain=1#L211-L215) -->
53
-
* ## Member location foundations
54
-
*
55
-
* The Spaces SDK is built upon existing Ably functionality available in Ably’s Core SDKs. Understanding which core features are used to provide the abstractions in the Spaces SDK enables you to manage space state and build additional functionality into your application.
56
-
*
57
-
* Member locations build upon the functionality of the Pub/Sub Channels [presence](https://ably.com/docs/presence-occupancy/presence) feature. Members are entered into the presence set when they {@link Space.enter | enter the space}.
58
-
*
59
-
* <!-- END WEBSITE DOCUMENTATION -->
60
-
*
61
-
* <!-- BEGIN CLASS-DEFINITIONS DOCUMENTATION -->
62
-
* Handles the tracking of member locations within a space. Inherits from {@link EventEmitter}.
* <!-- BEGIN WEBSITE DOCUMENTATION (https://github.com/ably/docs/blob/cb5de6a6a40abdcb0d9d5af825928dd62dc1ca64/content/spaces/locations.textile?plain=1#L15-L25) -->
107
-
* Use the `set()` method to emit a location event in realtime when a member changes their location. This will be received by all location subscribers to inform them of the location change. A `location` can be any JSON-serializable object, such as a slide number or element ID.
121
+
* Set the location of a member an emit an {@link LocationsEvents.UpdateEvent | `update`} event.
108
122
*
109
-
* A member must have been { @link Space.enter | entered } into the space to set their location.
123
+
* A `location` can be any JSON-serializable object, such as a slide number or element ID.
110
124
*
111
-
* The `set()` method is commonly combined with [`addEventListener()`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener) or a React [synthetic event](https://react.dev/learn/responding-to-events#adding-event-handlers), such as `onClick` or `onHover`.
125
+
* A member must have been {@link Space.enter | entered} into the space to set their location.
112
126
*
113
127
* The following is an example of a member setting their location to a specific slide number, and element on that slide:
* Set your current location. The `location` argument can be any JSON-serializable object. Emits a `locationUpdate` event to all connected clients in this space.
122
-
* <!-- END CLASS-DEFINITIONS DOCUMENTATION -->
123
-
*
124
-
* <!-- Second sentence copied from above -->
125
-
* @param location The new location. Can be any JSON-serializable object, such as a slide number or element ID.
133
+
* @param location The member's new location. Can be any JSON-serializable object.
* <!-- BEGIN WEBSITE DOCUMENTATION (https://github.com/ably/docs/blob/cb5de6a6a40abdcb0d9d5af825928dd62dc1ca64/content/spaces/locations.textile?plain=1#L29-L91) -->
142
-
* Subscribe to location events by registering a listener. Location events are emitted whenever a member changes location by calling {@link set}.
149
+
* Subscribe to location events by registering a listener. Location events are emitted whenever a member {@link Locations.set | changes} their location.
143
150
*
144
-
* All location changes are {@link LocationsEventMap.update | `update`} events. When a location update is received, clear the highlight from the UI component of the member’s {@link LocationsEvents.UpdateEvent.previousLocation | `previousLocation`} and add it to {@link LocationsEvents.UpdateEvent.currentLocation | `currentLocation`}.
151
+
* All location changes are `update` events. When a location update is received, clear the highlight from the UI component of the member’s {@link LocationsEvents.UpdateEvent.previousLocation | `previousLocation`} and add it to {@link LocationsEvents.UpdateEvent.currentLocation | `currentLocation`}.
145
152
*
146
153
* > **Note**
147
154
* >
148
-
* > A location update is also emitted when a member {@linkSpace.leave | leaves} a space. The member’s {@link LocationsEvents.UpdateEvent.currentLocation | `currentLocation` } will be `null` for these events so that any UI component highlighting can be cleared.
155
+
* > A location update is also emitted when a member is {@linkMembersEventMap.remove | removed} from a space. The member’s {@link LocationsEvents.UpdateEvent.currentLocation | `currentLocation` } will be `null` for these events so that any UI component highlighting can be cleared. Member location subscription listeners only trigger on events related to members’ locations. Each event only contains the payload of the member that triggered it. Alternatively, {@link Space.subscribe | space state } can be subscribed to which returns an array of all members with their latest state every time any event is triggered.
149
156
*
150
157
* The following is an example of subscribing to location events:
* The following is an example payload of a location event. Information about location is returned in {@link LocationsEvents.UpdateEvent.currentLocation | `currentLocation`} and {@link LocationsEvents.UpdateEvent.previousLocation | `previousLocation`}:
* The following are the properties of a location event payload:
189
-
*
190
-
* > **Moved documentation**
191
-
* >
192
-
* > This documentation has been moved to { @link LocationsEvents.UpdateEvent }.
193
-
*
194
-
* > **Further reading**
195
-
* >
196
-
* > Member location subscription listeners only trigger on events related to members’ locations. Each event only contains the payload of the member that triggered it. Alternatively, {@link Space.subscribe | space state } can be subscribed to which returns an array of all members with their latest state every time any event is triggered.
197
-
*
198
-
* <!-- END WEBSITE DOCUMENTATION -->
199
-
*
200
-
* <!-- BEGIN CLASS-DEFINITIONS DOCUMENTATION -->
201
-
* Listen to events for locations. See {@link EventEmitter} for overloaded usage.
202
-
*
203
-
* Available events:
204
-
*
205
-
* - ##### **update**
206
-
*
207
-
* Fires when a member updates their location. The argument supplied to the event listener is an UpdateEvent.
* The following is an example payload returned by `space.locations.getOthers()`: It will return the properties of all member’s `location` by their `connectionId`:
279
+
* Retrieve the location of all members in a one-off call.
369
280
*
370
-
* ```json
371
-
* {
372
-
* "xG6H3lnrCn": {
373
-
* "slide": "1",
374
-
* "component": "textBox-1"
375
-
* },
376
-
* "el29SVLktW": {
377
-
* "slide": "1",
378
-
* "component": "image-2"
379
-
* }
380
-
* }
381
-
* ```
382
-
* The following is an example of retrieving the location objects of all members, including the member themselves:
281
+
* The following is an example of retrieving the locations of all members:
* The following is an example payload returned by `space.locations.getAll()`. It will return the properties of all member’s `location` by their `connectionId`:
0 commit comments