import { Fetch } from './Query' ; import { invalidate } from './invalidate' ; import * as TE from 'fp-ts/lib/TaskEither' ; import { EnforceNonEmptyRecord , ProductA , ProductL , ObservableQueries , VoidInputObservableQueries } from './util' ; import * as O from 'fp-ts/lib/Option' ; import { pipe } from 'fp-ts/lib/pipeable' ; param cmd param queries export function command < A , L , P , I extends VoidInputObservableQueries , IL extends ProductL < I > > ( cmd , queries ) ; export function command < A , L , P , I extends ObservableQueries , IL extends ProductL < I > > ( cmd , queries ) ; export function command < A , L , P > ( cmd , queries ? ) ; export function command < A , L , P > ( cmd , queries ? ) ; export function command < A , L , P , I extends ObservableQueries , IL extends ProductL < I > > ( cmd , queries ? ) { return ( a , ia ) => TE . taskEither . chain ( cmd ( a ) , p => pipe ( queries , O . fromNullable , O . fold ( ( ) => TE . taskEither . of ( p ) , queries => TE . taskEither . map ( invalidate ( queries , ia ) , ( ) => p ) ) ) ) ; } export function contramap < U , L , A , B > ( fa , f ) { return a => fa ( f ( a ) ) ; }