import { StickerPackBuilder } from "../builders/builder" ; class _BuilderRegistry { private roomIdToBuilder : { [ roomId ] : StickerPackBuilder ; } = { } ; public register ( roomId , builder ) { if ( this . roomIdToBuilder [ roomId ] ) { throw new Error ( "An operation is already in progress" ) ; } this . roomIdToBuilder [ roomId ] = builder ; } public deregister ( roomId ) { delete this . roomIdToBuilder [ roomId ] ; } public handleEvent ( roomId , event ) { if ( this . roomIdToBuilder [ roomId ] ) { return this . roomIdToBuilder [ roomId ] . handleEvent ( event ) ; } else return Promise . resolve ( ) ; } public hasBuilder ( roomId ) { return ! ! this . roomIdToBuilder [ roomId ] ; } } export const BuilderRegistry = new _BuilderRegistry ( ) ;