Skip to content

Commit

Permalink
Add "Abstract" prefix to Types.{Rest, Realtime} names
Browse files Browse the repository at this point in the history
To avoid a clash with the top-level classes of the same name when we
remove the Types namespace in #909.
  • Loading branch information
lawrence-forooghian committed Nov 30, 2023
1 parent 1d0c7e9 commit d246033
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 21 deletions.
16 changes: 8 additions & 8 deletions ably.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ declare namespace Types {
}

/**
* Passes additional client-specific properties to the REST {@link Rest.constructor | `constructor()`} or the Realtime {@link Realtime.constructor | `constructor()`}.
* Passes additional client-specific properties to the REST {@link AbstractRest.constructor | `constructor()`} or the Realtime {@link AbstractRealtime.constructor | `constructor()`}.
*/
interface ClientOptions extends AuthOptions {
/**
Expand Down Expand Up @@ -1336,8 +1336,8 @@ declare namespace Types {
/**
* The `StatsParams` interface describes the parameters accepted by the following methods:
*
* - {@link Rest.stats}
* - {@link Realtime.stats}
* - {@link AbstractRest.stats}
* - {@link AbstractRealtime.stats}
*/
interface StatsParams {
/**
Expand Down Expand Up @@ -1658,7 +1658,7 @@ declare namespace Types {
/**
* A client that offers a simple stateless API to interact directly with Ably's REST API.
*/
abstract class Rest {
abstract class AbstractRest {
/**
* An {@link Types.Auth} object.
*/
Expand Down Expand Up @@ -1730,9 +1730,9 @@ declare namespace Types {
}

/**
* A client that extends the functionality of {@link Rest} and provides additional realtime-specific features.
* A client that extends the functionality of {@link AbstractRest} and provides additional realtime-specific features.
*/
abstract class Realtime {
abstract class AbstractRealtime {
/**
* A client ID, used for identifying this client when publishing messages or for presence purposes. The `clientId` can be any non-empty string, except it cannot contain a `*`. This option is primarily intended to be used in situations where the library is instantiated with a key. A `clientId` may also be implicit in a token used to instantiate the library; an error will be raised if a `clientId` specified here conflicts with the `clientId` implicit in the token.
*/
Expand Down Expand Up @@ -2765,7 +2765,7 @@ declare namespace Types {
/**
* A client that offers a simple stateless API to interact directly with Ably's REST API.
*/
export declare class Rest extends Types.Rest {
export declare class Rest extends Types.AbstractRest {
/**
* Construct a client object using an Ably {@link Types.ClientOptions} object.
*
Expand Down Expand Up @@ -2795,7 +2795,7 @@ export declare class Rest extends Types.Rest {
/**
* A client that extends the functionality of {@link Rest} and provides additional realtime-specific features.
*/
export declare class Realtime extends Types.Realtime {
export declare class Realtime extends Types.AbstractRealtime {
/**
* Construct a client object using an Ably {@link Types.ClientOptions} object.
*
Expand Down
4 changes: 2 additions & 2 deletions modules.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export interface ModulesMap {
*
* `BaseRest` is the equivalent, in the modular variant of the Ably Client Library SDK, of the [`Rest`](../../default/classes/Rest.html) class in the default variant of the SDK. The difference is that its constructor allows you to decide exactly which functionality the client should include. This allows unused functionality to be tree-shaken, reducing bundle size.
*/
export declare class BaseRest extends Types.Rest {
export declare class BaseRest extends Types.AbstractRest {
/**
* Construct a client object using an Ably {@link Types.ClientOptions} object.
*
Expand All @@ -261,7 +261,7 @@ export declare class BaseRest extends Types.Rest {
*
* `BaseRealtime` is the equivalent, in the modular variant of the Ably Client Library SDK, of the [`Realtime`](../../default/classes/Realtime.html) class in the default variant of the SDK. The difference is that its constructor allows you to decide exactly which functionality the client should include. This allows unused functionality to be tree-shaken, reducing bundle size.
*/
export declare class BaseRealtime extends Types.Realtime {
export declare class BaseRealtime extends Types.AbstractRealtime {
/**
* Construct a client object using an Ably {@link Types.ClientOptions} object.
*
Expand Down
4 changes: 2 additions & 2 deletions src/platform/react-hooks/src/AblyProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ const canUseSymbol = typeof Symbol === 'function' && typeof Symbol.for === 'func

interface AblyProviderProps {
children?: React.ReactNode | React.ReactNode[] | null;
client?: Ably.Types.Realtime;
client?: Ably.Types.AbstractRealtime;
id?: string;
}

type AblyContextType = React.Context<Types.Realtime>;
type AblyContextType = React.Context<Types.AbstractRealtime>;

// An object is appended to `React.createContext` which stores all contexts
// indexed by id, which is used by useAbly to find the correct context when an
Expand Down
4 changes: 2 additions & 2 deletions src/platform/react-hooks/src/hooks/useAbly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React from 'react';
import { getContext } from '../AblyProvider.js';
import * as API from '../../../../../ably.js';

export function useAbly(id = 'default'): API.Types.Realtime {
const client = React.useContext(getContext(id)) as API.Types.Realtime;
export function useAbly(id = 'default'): API.Types.AbstractRealtime {
const client = React.useContext(getContext(id)) as API.Types.AbstractRealtime;

if (!client) {
throw new Error(
Expand Down
4 changes: 2 additions & 2 deletions src/platform/react-hooks/src/hooks/useChannel.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { act } from 'react-dom/test-utils';
import { AblyProvider } from '../AblyProvider.js';

function renderInCtxProvider(client: FakeAblySdk, children: React.ReactNode | React.ReactNode[]) {
return render(<AblyProvider client={client as unknown as Types.Realtime}>{children}</AblyProvider>);
return render(<AblyProvider client={client as unknown as Types.AbstractRealtime}>{children}</AblyProvider>);
}

describe('useChannel', () => {
Expand Down Expand Up @@ -57,7 +57,7 @@ describe('useChannel', () => {
it('useChannel works with multiple clients', async () => {
renderInCtxProvider(
ablyClient,
<AblyProvider client={otherClient as unknown as Types.Realtime} id="otherClient">
<AblyProvider client={otherClient as unknown as Types.AbstractRealtime} id="otherClient">
<UseChannelComponentMultipleClients />
</AblyProvider>
);
Expand Down
2 changes: 1 addition & 1 deletion src/platform/react-hooks/src/hooks/useChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type AblyMessageCallback = Types.messageCallback<Types.Message>;

export interface ChannelResult {
channel: Types.RealtimeChannel;
ably: Types.Realtime;
ably: Types.AbstractRealtime;
connectionError: ErrorInfo | null;
channelError: ErrorInfo | null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { act } from 'react-dom/test-utils';
import { AblyProvider } from '../AblyProvider.js';

function renderInCtxProvider(client: FakeAblySdk, children: React.ReactNode | React.ReactNode[]) {
return render(<AblyProvider client={client as unknown as Types.Realtime}>{children}</AblyProvider>);
return render(<AblyProvider client={client as unknown as Types.AbstractRealtime}>{children}</AblyProvider>);
}

describe('useChannelStateListener', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { AblyProvider } from '../AblyProvider.js';
import { useConnectionStateListener } from './useConnectionStateListener.js';

function renderInCtxProvider(client: FakeAblySdk, children: React.ReactNode | React.ReactNode[]) {
return render(<AblyProvider client={client as unknown as Types.Realtime}>{children}</AblyProvider>);
return render(<AblyProvider client={client as unknown as Types.AbstractRealtime}>{children}</AblyProvider>);
}

describe('useConnectionStateListener', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/platform/react-hooks/src/hooks/usePresence.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { AblyProvider } from '../AblyProvider.js';
import { Types, ErrorInfo } from '../../../../../ably.js';

function renderInCtxProvider(client: FakeAblySdk, children: React.ReactNode | React.ReactNode[]) {
return render(<AblyProvider client={client as unknown as Types.Realtime}>{children}</AblyProvider>);
return render(<AblyProvider client={client as unknown as Types.AbstractRealtime}>{children}</AblyProvider>);
}

const testChannelName = 'testChannel';
Expand Down Expand Up @@ -97,7 +97,7 @@ describe('usePresence', () => {
it('usePresence works with multiple clients', async () => {
renderInCtxProvider(
ablyClient,
<AblyProvider id="otherClient" client={otherClient as unknown as Types.Realtime}>
<AblyProvider id="otherClient" client={otherClient as unknown as Types.AbstractRealtime}>
<UsePresenceComponentMultipleClients />
</AblyProvider>
);
Expand Down

0 comments on commit d246033

Please sign in to comment.