botui
Version:
Build customizable conversational UIs and bots
22 lines (19 loc) • 527 B
text/typescript
import type { Block, BlockData, BlockMeta } from './block.js'
export interface ActionInterface {
get: () => Promise<Block>
set: (data: BlockData, meta: BlockMeta) => Promise<any>
}
export function actionManager(callback = (action: Block | null) => {}) {
let currentAction: Block | null = null
return {
get: () => currentAction,
set: (action: Block) => {
currentAction = action
callback(currentAction)
},
clear: () => {
currentAction = null
callback(currentAction)
},
}
}