mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 15:27:05 +00:00
[pubnub] Added "history" method with following interfaces:
HistoryParameters, HistoryMessage, HistoryResponse, HistoryStatus
This commit is contained in:
Vendored
+40
-1
@@ -1,6 +1,10 @@
|
||||
// Type definitions for pubnub 4.0
|
||||
// Project: https://github.com/pubnub/javascript
|
||||
// Definitions by: bitbankinc <https://github.com/bitbankinc>, rollymaduk <https://github.com/rollymaduk>, vitosamson <https://github.com/vitosamson>, FlorianDr <https://github.com/FlorianDr>
|
||||
// Definitions by: bitbankinc <https://github.com/bitbankinc>,
|
||||
// rollymaduk <https://github.com/rollymaduk>,
|
||||
// vitosamson <https://github.com/vitosamson>,
|
||||
// FlorianDr <https://github.com/FlorianDr>,
|
||||
// danduh <https://github.com/danduh>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// @see https://www.pubnub.com/docs/web-javascript/api-reference-configuration
|
||||
// TypeScript Version: 2.2
|
||||
@@ -42,6 +46,11 @@ declare class Pubnub {
|
||||
params: Pubnub.FireParameters
|
||||
): Promise<Pubnub.PublishResponse>;
|
||||
|
||||
history(
|
||||
params: Pubnub.HistoryParameters,
|
||||
callback: (status: Pubnub.HistoryStatus, response: Pubnub.HistoryResponse) => void
|
||||
): void;
|
||||
|
||||
subscribe(params: Pubnub.SubscribeParameters): void;
|
||||
|
||||
unsubscribe(params: Pubnub.UnsubscribeParameters): void;
|
||||
@@ -193,6 +202,34 @@ declare namespace Pubnub {
|
||||
timetoken: number;
|
||||
}
|
||||
|
||||
interface HistoryParameters {
|
||||
channel: string;
|
||||
count: number;
|
||||
stringifiedTimeToken?: boolean;
|
||||
includeTimetoken?: boolean;
|
||||
reverse?: boolean;
|
||||
start?: number; // timetoken
|
||||
end?: number; // timetoken
|
||||
}
|
||||
|
||||
interface HistoryMessage {
|
||||
entry: any;
|
||||
timetoken?: string | number;
|
||||
}
|
||||
|
||||
interface HistoryResponse {
|
||||
endTimeToken?: number;
|
||||
startTimeToken?: number;
|
||||
messages: HistoryMessage[];
|
||||
}
|
||||
|
||||
interface HistoryStatus {
|
||||
error: boolean;
|
||||
errorData?: Error;
|
||||
operation: string; // see Pubnub.Operations
|
||||
statusCode?: number;
|
||||
}
|
||||
|
||||
interface PublishStatus {
|
||||
operation: string; // see Pubnub.Operations
|
||||
category: string; // see Pubnub.Categories;
|
||||
@@ -225,7 +262,9 @@ declare namespace Pubnub {
|
||||
// addListener
|
||||
interface ListenerParameters {
|
||||
status?(statusEvent: StatusEvent): void;
|
||||
|
||||
message?(messageEvent: MessageEvent): void;
|
||||
|
||||
presence?(presenceEvent: PresenceEvent): void;
|
||||
}
|
||||
|
||||
|
||||
@@ -87,6 +87,11 @@ pubnub.setState({ channels: [] }).then(res => {
|
||||
console.log(res.state);
|
||||
});
|
||||
|
||||
pubnub.history({channel: 'channel-1', count: 2}, (status, res) => {
|
||||
console.log(status);
|
||||
console.log(res);
|
||||
});
|
||||
|
||||
const cryptoOptions = {
|
||||
encryptKey: true,
|
||||
keyEncoding: 'utf8',
|
||||
|
||||
Reference in New Issue
Block a user