@sanity/sdk
Version:
19 lines (17 loc) • 543 B
text/typescript
import {defineStore} from '../store/defineStore'
import {subscribeToStateAndFetchBatches} from './subscribeToStateAndFetchBatches'
import {type ProjectionStoreState} from './types'
export const projectionStore = defineStore<ProjectionStoreState>({
name: 'Projection',
getInitialState() {
return {
values: {},
documentProjections: {},
subscriptions: {},
}
},
initialize(context) {
const batchSubscription = subscribeToStateAndFetchBatches(context)
return () => batchSubscription.unsubscribe()
},
})