import { Observable } from 'rxjs/Observable' ; import { Query } from '../../interface' ; import { mapFn } from './mapFn' ; export class ProxySelector < T > { public request$ : Observable < T [ ] > ; private mapFn = mapFn ; constructor ( request$ , public query , public tableName ) { this . request$ = request$ . map ( ( r ) => { if ( Array . isArray ( r ) ) { return r ; } else { return [ r ] ; } } ) ; } values ( ) { return this . mapFn ( this . request$ ) ; } changes ( ) { return this . mapFn ( this . request$ ) ; } map < K > ( fn ) { this . mapFn = fn ; return this as any as ProxySelector < K > ; } }