-
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.
Remove Message-related static things in tree-shakable library
This removes the static BaseClient.Message property and the static Message.{fromEncoded, fromEncodedArray} methods. The motivation, and the approach taken for the tree-shakable and non tree-shakable versions of the library, are as in c859b90. Note that instead of fromEncoded and fromEncodedArray, the standalone functions are named decodeMessage and decodeMessages — after some discussion we decided that this naming was more consistent with the kind of naming used for standalone functions in JavaScript libraries.
- Loading branch information
1 parent
5cc2c13
commit 601b46b
Showing
9 changed files
with
119 additions
and
12 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
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import Message, { fromEncoded, fromEncodedArray } from './message'; | ||
import * as API from '../../../../ably'; | ||
import Platform from 'common/platform'; | ||
|
||
/** | ||
`DefaultMessage` is the class returned by `DefaultRest` and `DefaultRealtime`’s `Message` static property. It introduces the static methods described in the `MessageStatic` interface of the public API of the non tree-shakable version of the library. | ||
*/ | ||
export class DefaultMessage extends Message { | ||
static async fromEncoded(encoded: unknown, inputOptions?: API.Types.ChannelOptions): Promise<Message> { | ||
return fromEncoded(Platform.Crypto, encoded, inputOptions); | ||
} | ||
|
||
static async fromEncodedArray(encodedArray: Array<unknown>, options?: API.Types.ChannelOptions): Promise<Message[]> { | ||
return fromEncodedArray(Platform.Crypto, encodedArray, options); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import * as API from '../../../../ably'; | ||
import Platform from 'common/platform'; | ||
import { fromEncoded, fromEncodedArray } from '../../../common/lib/types/message'; | ||
|
||
// The type assertions for the decode* functions below are due to https://github.com/ably/ably-js/issues/1421 | ||
|
||
export const decodeMessage = ((obj, options) => { | ||
return fromEncoded(Platform.Crypto, obj, options); | ||
}) as API.Types.MessageStatic['fromEncoded']; | ||
|
||
export const decodeMessages = ((obj, options) => { | ||
return fromEncodedArray(Platform.Crypto, obj, options); | ||
}) as API.Types.MessageStatic['fromEncodedArray']; |
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