Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@meteorrn/core",
"version": "2.9.0",
"description": "Full Meteor Client for React Native",
"types": "src/Meteor.d.ts",
"main": "src/index.js",
"repository": {
"type": "git",
Expand Down
74 changes: 54 additions & 20 deletions src/Meteor.d.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
import { AsyncStorageStatic } from "@react-native-async-storage/async-storage";

declare module '@meteorrn/core' {
type Callback = (...args: unknown[]) => void;

function connect(endpoint: string, options?: any): void;
function disconnect(): void;
function reconnect(): void;

type Status =
| 'change'
| 'connected'
| 'disconnected'
| 'loggingIn'
| 'loggingOut';

function call(...args: any[]): void;
function status(): {
connected: boolean;
status: Status;
};

function logout(cb: Callback): void;
function loggingOut(): boolean;
function loggingIn(): boolean;
type useTracker<T> = (cb: () => T) => T

interface Data {
getUrl(): string;
Expand All @@ -35,7 +26,12 @@ declare module '@meteorrn/core' {
socket: unknown;
};
}
function getData(): Data;

interface MeteorError {
error: string
reason?: string
details?: string
}

interface User {
_id: string;
Expand All @@ -45,15 +41,53 @@ declare module '@meteorrn/core' {
settings: {};
};
}
function user(): User | undefined;

interface ConnectOptions {
suppressUrlErrors: boolean
AsyncStorage: AsyncStorageStatic
reachabilityUrl: string
}

interface Meteor {
connect(endpoint: string, options?: ConnectOptions): void;
disconnect(): void;
reconnect(): void;

call(...args: any[]): void;
status(): {
connected: boolean;
status: Status;
};

logout(cb: Callback): void;
loggingOut(): boolean;
loggingIn(): boolean;

getData(): Data;
user(): User | undefined;
getAuthToken(): string;

readonly isVerbose: boolean;
enableVerbose(): void;

useTracker<T>(): useTracker<T>;

ddp: Data;

_handleLoginCallback(err: MeteorError | null | undefined, res: { token: string, id: string }): void;
}

interface Accounts {
onLogin(cb: Callback): void;
}
function getAuthToken(): string;

const ddp: Data;
let isVerbose: boolean;
function _handleLoginCallback(err: any, res: any): void;
// Export default Meteor object
const Meteor: Meteor;
export default Meteor;

function useTracker<T>(cb: () => T): T;
// Export other members
export {
useTracker,
Accounts,
}
}
Loading