Skip to content

Commit

Permalink
Change 'cursorsUpdate' event to 'update'
Browse files Browse the repository at this point in the history
The API states that a namespace should use `update` for the event name
rather than `cursorUpdate`.
  • Loading branch information
surminus committed Aug 22, 2023
1 parent 55972dd commit 86253eb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions demo/src/components/Cursors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const Cursors = () => {
useEffect(() => {
if (!space || !members) return;

space.cursors.subscribe('cursorsUpdate', (cursorUpdate) => {
space.cursors.subscribe('update', (cursorUpdate) => {
const { connectionId } = cursorUpdate;
const member = find<Member>(members, { connectionId });

Expand Down Expand Up @@ -89,7 +89,7 @@ export const Cursors = () => {
});

return () => {
space.cursors.unsubscribe('cursorsUpdate');
space.cursors.unsubscribe('update');
};
}, [space, members]);

Expand Down
2 changes: 1 addition & 1 deletion src/Cursors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('Cursors', () => {
context.space = new Space('test', client);
context.cursors = context.space.cursors;
// This will set the channel
context.cursors.subscribe('cursorsUpdate', () => {});
context.cursors.subscribe('update', () => {});
context.channel = context.cursors['channel'] as Types.RealtimeChannelPromise;
context.batching = context.space.cursors['cursorBatching'];
context.dispensing = context.space.cursors['cursorDispensing'];
Expand Down
4 changes: 2 additions & 2 deletions src/Cursors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type { CursorsOptions, CursorUpdate } from './types.js';
import type { RealtimeMessage } from './utilities/types.js';

type CursorsEventMap = {
cursorsUpdate: CursorUpdate;
update: CursorUpdate;
};

export default class Cursors extends EventEmitter<CursorsEventMap> {
Expand All @@ -34,7 +34,7 @@ export default class Cursors extends EventEmitter<CursorsEventMap> {
this.cursorHistory = new CursorHistory();
this.cursorBatching = new CursorBatching(this.options.outboundBatchInterval);

const emitCursorUpdate = (update: CursorUpdate): void => this.emit('cursorsUpdate', update);
const emitCursorUpdate = (update: CursorUpdate): void => this.emit('update', update);
this.cursorDispensing = new CursorDispensing(emitCursorUpdate);
}

Expand Down

0 comments on commit 86253eb

Please sign in to comment.