import type { $Slice , Container , Slice } from '../context' ; import type { Clock , Timer } from '../timing' ; /**
 * The ctx object that can be accessed in plugin and action.
 */ export class Ctx { #container : Container ; #clock : Clock ; constructor ( container , clock ) { this . #container = container ; this . #clock = clock ; } param slice returns readonly use = < T > ( slice ) : $Slice < T > => this . #container . getSlice ( slice ) ; param slice returns readonly get = < T > ( slice ) => this . use ( slice ) . get ( ) ; param slice returns readonly set = < T > ( slice , value ) => this . use ( slice ) . set ( value ) ; example param slice param updater returns readonly update = < T > ( slice , updater ) => this . use ( slice ) . update ( updater ) ; param timer returns readonly timing = ( timer ) => this . #clock . get ( timer ) ; param timer returns readonly wait = ( timer ) => this . timing ( timer ) ( ) ; param timer returns readonly done = ( timer ) => this . timing ( timer ) . done ( ) ; param slice returns readonly waitTimers = async ( slice ) => { await Promise . all ( this . get ( slice ) . map ( ( x ) => this . wait ( x ) ) ) ; return ; } ; }