import { atom , observe } from 'elementos' ; export const createInterval = ( initialCallback , interval ) => { const interval$ = atom ( interval ) ; let callback = initialCallback ; const dispose = observe ( interval$ , ( ms ) => { const id = setInterval ( ( ) => { callback ( ) ; } , ms ) ; return ( ) => { clearInterval ( id ) ; } ; } ) ; return { setInterval : ( milliseconds ) => { interval$ . actions . set ( milliseconds ) ; } , setCallback : ( nextCallback ) => { callback = nextCallback ; } , dispose } ; } ;