import * as React from 'react' ; import { Provider } from "polar-shared/src/util/Providers" ; import { FlashcardSide } from "./FlashcardCard" ; import { createObservableStore , SetStore } from "../../../../../web/js/react/store/ObservableStore" ; interface IFlashcardStore { readonly side : FlashcardSide ; } interface IFlashcardCallbacks { readonly setSide : ( side : FlashcardSide ) => void ; } const initialStore = { side : 'front' } ; interface Mutator { } function mutatorFactory < A > ( storeProvider , setStore ) { return { } ; } function useCallbacksFactory ( storeProvider , setStore , mutator ) { return React . useMemo ( ( ) => { function setSide ( side ) { const store = storeProvider ( ) ; setStore ( { ... store , side } ) ; } return { setSide } ; } , [ setStore , storeProvider ] ) ; } export const [ FlashcardStoreProvider , useFlashcardStore , useFlashcardCallbacks ] = createObservableStore < IFlashcardStore , Mutator , IFlashcardCallbacks > ( { initialValue : initialStore , mutatorFactory , callbacksFactory : useCallbacksFactory } ) ;