import { ObservableQuery , queryStrict } from './Query' ; import * as TE from 'fp-ts/lib/TaskEither' ; import { IORef } from 'fp-ts/lib/IORef' ; import { refetch } from './Strategy' ; import { command as _command } from './command' ; import * as IO from 'fp-ts/lib/IO' ; import * as E from 'fp-ts/lib/Either' ; param initialValue export function memoryValue < T > ( initialValue ) { const ref = new IORef ( initialValue ) ; const fetch = ( ) => TE . fromIOEither < void , T > ( IO . io . map ( ref . read , E . right ) ) ; const query = queryStrict ( fetch , refetch ) ; const command = _command ( ( value ) => TE . fromIOEither < void , void > ( IO . io . map ( ref . write ( value ) , E . right ) ) , { query } ) ; return { query , command , get : ref . read , set : ref . write } ; }