import { ResultTreeHandler } from '../result-tree/result-tree-handler' ; import { QueryTreeNode } from '../query-tree/query-tree-node' ; import { JSONDecoderHandler } from './json-decoder-handler' ; import { Query } from '../query-tree/query' ; import { RunningQuery } from '../client/query' ; export class JSONDecoder { private result : any = { } ; private dirty = false ; constructor ( private qnode , private query , private resultCb ? ) { } public getResult ( ) { return this . result ; } public flush ( ) { this . dirty = false ; if ( this . resultCb ) { this . resultCb ( this . result ) ; } } public getResultHandler ( ) { let qmap = this . query . getQueryMap ( ) || undefined ; let handler = new JSONDecoderHandler ( qmap , ( ) => { this . dirty = true ; } ) ; handler . qnode = this . qnode ; handler . value = this . result ; return handler . handleValue . bind ( handler ) ; } }