@telegram-apps/sdk
Version:
TypeScript Source Development Kit for Telegram Mini Apps client application.
96 lines (95 loc) • 3.63 kB
TypeScript
import { EventListener } from '@telegram-apps/bridge';
/**
* Signal indicating if the Back Button is currently visible.
*/
export declare const _isVisible: import('@telegram-apps/signals').Signal<boolean>, isVisible: import('@telegram-apps/signals').Computed<boolean>;
/**
* Signal indicating if the Back Button is currently mounted.
*/
export declare const _isMounted: import('@telegram-apps/signals').Signal<boolean>, isMounted: import('@telegram-apps/signals').Computed<boolean>;
/**
* Signal indicating if the Back Button is supported.
*/
export declare const isSupported: import('@telegram-apps/signals').Computed<boolean>;
/**
* Hides the Back Button.
* @param
* @throws {FunctionNotAvailableError} The environment is unknown
* @throws {FunctionNotAvailableError} The SDK is not initialized
* @throws {FunctionNotAvailableError} The function is not supported
* @throws {FunctionNotAvailableError} The parent component is not mounted
* @since Mini Apps v6.1
* @example
* if (hide.isAvailable()) {
* hide();
* }
*/
export declare const hide: import('../../wrappers/wrapSafe.js').SafeWrapped<() => void, true, never>;
/**
* Mounts the Back Button restoring its state.
* @param
* @throws {FunctionNotAvailableError} The environment is unknown
* @throws {FunctionNotAvailableError} The SDK is not initialized
* @throws {FunctionNotAvailableError} The function is not supported
* @since Mini Apps v6.1
* @example
* if (mount.isAvailable()) {
* mount();
* }
*/
export declare const mount: import('../../wrappers/wrapSafe.js').SafeWrapped<() => void, true, never>;
/**
* Adds a new Back Button click listener.
* @param fn - event listener.
* @returns A function to remove bound listener.
* @throws {FunctionNotAvailableError} The environment is unknown
* @throws {FunctionNotAvailableError} The SDK is not initialized
* @throws {FunctionNotAvailableError} The function is not supported
* @since Mini Apps v6.1
* @example
* if (onClick.isAvailable()) {
* const off = onClick(() => {
* console.log('User clicked the Back Button');
* off();
* });
* }
*/
export declare const onClick: import('../../wrappers/wrapSafe.js').SafeWrapped<(fn: EventListener<"back_button_pressed">) => VoidFunction, true, never>;
/**
* Removes the Back Button click listener.
* @param fn - an event listener.
* @throws {FunctionNotAvailableError} The environment is unknown
* @throws {FunctionNotAvailableError} The SDK is not initialized
* @throws {FunctionNotAvailableError} The function is not supported
* @since Mini Apps v6.1
* @example
* if (offClick.isAvailable()) {
* function listener() {
* console.log('User clicked the Back Button');
* offClick(listener);
* }
* onClick(listener);
* }
*/
export declare const offClick: import('../../wrappers/wrapSafe.js').SafeWrapped<(fn: EventListener<"back_button_pressed">) => void, true, never>;
/**
* Shows the Back Button.
* @throws {FunctionNotAvailableError} The environment is unknown
* @throws {FunctionNotAvailableError} The SDK is not initialized
* @throws {FunctionNotAvailableError} The function is not supported
* @throws {FunctionNotAvailableError} The parent component is not mounted
* @since Mini Apps v6.1
* @example
* if (show.isAvailable()) {
* show();
* }
*/
export declare const show: import('../../wrappers/wrapSafe.js').SafeWrapped<() => void, true, never>;
/**
* Unmounts the Back Button.
*
* Note that this function does not remove listeners added via the `onClick`
* function, so you have to remove them on your own.
* @see onClick
*/
export declare function unmount(): void;