@puregram/scenes
Version:
Simple implementation of middleware-based scene management for puregram
29 lines (28 loc) • 1.13 kB
TypeScript
import { SessionContext } from '../types';
import { SceneContextOptions, SceneContextEnterOptions, SceneContextLeaveOptions, LastAction } from './scene.types';
export declare class SceneContext<S extends Record<string, unknown> = Record<string, any>> {
/** Lazy session for submodules */
session: SessionContext;
/** Base namespace for user input */
state: S;
/** Is the scene cancelled? Used in `leaveHandler()` */
cancelled: boolean;
lastAction: LastAction;
/** Controlled behavior leave */
leaving: boolean;
private readonly context;
private repository;
constructor(options: SceneContextOptions);
/** Returns current scene */
get current(): import("..").SceneInterface | undefined;
/** Enter to scene */
enter(slug: string, options?: SceneContextEnterOptions<S>): Promise<void>;
/** Reenter to current scene */
reenter(): Promise<void>;
/** Leave from current scene */
leave(options?: SceneContextLeaveOptions): Promise<void>;
/** Reset state/session */
reset(): void;
/** Updates session and state is lazy */
private updateSession;
}