import { ReadableAtom } from '..' ; import * as cb from 'callbag' ; export const atomToSource = < T > ( atom ) : cb . Source < T > => { return ( type , data ) => { if ( type === 0 ) { const sink = data ; let unsubscribe = atom . subscribe ( value => { sink ( 1 , value ) ; } ) ; const talkback = ( t ) => { if ( t === 2 ) unsubscribe ( ) ; } ; sink ( 0 , talkback ) ; } } ; } ;