presence-related fixes (#1361)

This fixes a bug where creating a page would fail if there were multiple
pages with the same index.

This also changes the store to use a throttled version of
requestAnimationFrame. This should be good for relieving backpressure in
situations where the store is updated many times in quick succession. It
also makes testing a lot easier since it has the mocking logic built in.

### Change Type

- [x] `patch` — Bug Fix


### Release Notes

- Fix a bug where creating a page could throw an error in some
multiplayer contexts.
This commit is contained in:
David Sheldrick 2023-05-12 10:43:51 +01:00 committed by GitHub
parent 9ccd0f480f
commit d76446646c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 128 additions and 15 deletions

View file

@ -122,6 +122,9 @@ export function promiseWithResolve<T>(): Promise<T> & {
reject: (reason?: any) => void;
};
// @internal
export function rafThrottle(fn: () => void): () => void;
// @public (undocumented)
export type Result<T, E> = ErrorResult<E> | OkResult<T>;
@ -144,6 +147,9 @@ export { structuredClone_2 as structuredClone }
// @public
export function throttle<T extends (...args: any) => any>(func: T, limit: number): (...args: Parameters<T>) => ReturnType<T>;
// @internal
export function throttledRaf(fn: () => void): void;
// (No @packageDocumentation comment for this package)
```