session API
The session api provides you with information on the current user's coding session in the workspace.
Usage
import { session } from '@replit/extensions';
Methods
session.onActiveFileChange
Sets up a listener to handle when the active file is changed
onActiveFileChange(listener: OnActiveFileChangeListener): DisposerFunction
session.getActiveFile
Returns the current file the user is focusing
getActiveFile(): Promise<null | string>
Types
DisposerFunction
A cleanup/disposer function (void)
() => void
OnActiveFileChangeListener
Fires when the current user switches to a different file/tool in the workspace. Returns null if the current file/tool cannot be found in the filesystem.
(file: string | ) => void