-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tighten up type in places where transport name is used
- Loading branch information
1 parent
dbdead7
commit 8a9faaa
Showing
11 changed files
with
48 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
enum TransportName { | ||
WebSocket = 'web_socket', | ||
Comet = 'comet', | ||
XhrStreaming = 'xhr_streaming', | ||
XhrPolling = 'xhr_polling', | ||
export namespace TransportNames { | ||
export const WebSocket = 'web_socket' as const; | ||
export const Comet = 'comet' as const; | ||
export const XhrStreaming = 'xhr_streaming' as const; | ||
export const XhrPolling = 'xhr_polling' as const; | ||
} | ||
|
||
type TransportName = | ||
| typeof TransportNames.WebSocket | ||
| typeof TransportNames.Comet | ||
| typeof TransportNames.XhrStreaming | ||
| typeof TransportNames.XhrPolling; | ||
|
||
export default TransportName; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import TransportName from 'common/constants/TransportName'; | ||
import { TransportNames } from 'common/constants/TransportName'; | ||
import initialiseNodeCometTransport from './nodecomettransport'; | ||
|
||
export default { | ||
order: [TransportName.Comet], | ||
implementations: { [TransportName.Comet]: initialiseNodeCometTransport }, | ||
order: [TransportNames.Comet], | ||
implementations: { [TransportNames.Comet]: initialiseNodeCometTransport }, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import TransportName from 'common/constants/TransportName'; | ||
import { TransportNames } from 'common/constants/TransportName'; | ||
import initialiseXHRPollingTransport from './xhrpollingtransport'; | ||
import initialiseXHRStreamingTransport from './xhrstreamingtransport'; | ||
|
||
export default { | ||
order: [TransportName.XhrPolling, TransportName.XhrStreaming], | ||
order: [TransportNames.XhrPolling, TransportNames.XhrStreaming], | ||
implementations: { | ||
[TransportName.XhrPolling]: initialiseXHRPollingTransport, | ||
[TransportName.XhrStreaming]: initialiseXHRStreamingTransport, | ||
[TransportNames.XhrPolling]: initialiseXHRPollingTransport, | ||
[TransportNames.XhrStreaming]: initialiseXHRStreamingTransport, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import IDefaults from 'common/types/IDefaults'; | ||
import TransportName from 'common/constants/TransportName'; | ||
import { TransportNames } from 'common/constants/TransportName'; | ||
|
||
const Defaults: IDefaults = { | ||
connectivityCheckUrl: 'https://internet-up.ably-realtime.com/is-the-internet-up.txt', | ||
/* Order matters here: the base transport is the leftmost one in the | ||
* intersection of baseTransportOrder and the transports clientOption that's | ||
* supported. */ | ||
defaultTransports: [TransportName.XhrPolling, TransportName.XhrStreaming, TransportName.WebSocket], | ||
baseTransportOrder: [TransportName.XhrPolling, TransportName.XhrStreaming, TransportName.WebSocket], | ||
transportPreferenceOrder: [TransportName.XhrPolling, TransportName.XhrStreaming, TransportName.WebSocket], | ||
upgradeTransports: [TransportName.XhrStreaming, TransportName.WebSocket], | ||
defaultTransports: [TransportNames.XhrPolling, TransportNames.XhrStreaming, TransportNames.WebSocket], | ||
baseTransportOrder: [TransportNames.XhrPolling, TransportNames.XhrStreaming, TransportNames.WebSocket], | ||
transportPreferenceOrder: [TransportNames.XhrPolling, TransportNames.XhrStreaming, TransportNames.WebSocket], | ||
upgradeTransports: [TransportNames.XhrStreaming, TransportNames.WebSocket], | ||
}; | ||
|
||
export default Defaults; |