import React from 'react'
import type { Context } from './types'

const error = 'Cannot use grid context without a provider'

const errorHandler = () => {
    throw new Error(error)
}

export const GridContext = React.createContext<Context>({
    dispatch: errorHandler,
    getState: errorHandler,
    subscribe: errorHandler,
    events: {
        on: errorHandler,
        emit: errorHandler,
    },
    // TODO: how to handle error handling without representing
    // ever possible api method here
    api: null as any,
    selectors: null as any,
})
