Description Coordinates commit boundaries for expression evaluation. Internally, expression evaluate managers subscribe once and flush pending work when commits are triggered.
It also provides a shared microtask queue via scheduleDirtyFlush(...) so multiple dirty managers can flush once per microtask instead of creating independent flush loops.
Parameters listener () => void
Commit listener passed to subscribeCommitted ( listener ). Returns an unsubscribe function .
manager IDirtyFlushable
Dirty manager passed to scheduleDirtyFlush ( manager ). Must expose flush (): void .
suspend() , continue() , and commit() do not take parameters.
Return type All control methods return void .
subscribeCommitted(...) returns an unsubscribe callback.
Usage notes suspend() pauses automatic flushing when state-manager cycles end.
continue() resumes and immediately triggers commit() .
Keep suspend() / continue() calls balanced. continue() decrements internal suspend depth.
Internal lifecycle subscribeCommitted(...) listeners are one-shot per commit call. Internally, listeners are copied, cleared, then invoked.
scheduleDirtyFlush(...) batches dirty managers in a shared set and flushes them in the next microtask using queueMicrotask .
If suspended, commit() is ignored until suspension depth returns to zero.
export type IExpressionCommitListener = ( ) => void ;
export interface IDirtyFlushable {
flush ( ) : void ;
}
export interface IExpressionChangeTransactionManager extends IDisposable {
subscribeCommitted ( listener : IExpressionCommitListener ) : ( ) => void ;
suspend ( ) : void ;
continue ( ) : void ;
commit ( ) : void ;
scheduleDirtyFlush ( manager : IDirtyFlushable ) : void ;
} import { InjectionContainer } from '@rs-x/core' ;
import {
type IExpressionChangeTransactionManager ,
rsx ,
RsXExpressionParserInjectionTokens ,
RsXExpressionParserModule ,
} from '@rs-x/expression-parser' ;
await InjectionContainer . load ( RsXExpressionParserModule ) ;
const tx = InjectionContainer . get < IExpressionChangeTransactionManager > (
RsXExpressionParserInjectionTokens . IExpressionChangeTransactionManager
) ;
const model = { a : 1 , b : 2 } ;
const expression = rsx < number > ( 'a + b' ) ( model ) ;
const unsubscribeCommitted = tx . subscribeCommitted ( ( ) => {
console . log ( 'commit boundary reached' ) ;
} ) ;
expression . changed . subscribe ( ( ) => { Show full code