import { getContext } from "typed-redux-saga" ; import { GetContextEffect } from "../effects" ; export type GetVariableFn < TVariables > = < TResult > ( selector : ( variables : TVariables ) => TResult ) => TResult ; export type UpdateVariablesFn < TVariables > = ( patch : Partial < TVariables > ) => void ; param getVariable param updateVariables export type VariablesStoreContext < TVariables > = { getVariable : GetVariableFn < TVariables > ; updateVariables : UpdateVariablesFn < TVariables > ; } ; /**
 * Select a variable from the variable store
 *
 * Accessor for `getVariable` in the  VariablesStoreContext typeParam typeParam param selector returns export const getVariable = function * < TVariables , TResult > ( selector ) { return ( yield * getContext < GetVariableFn < TVariables > > ( "getVariable" ) ) ( selector ) ; } ; /**
 * Update a/some variable(s) in the variable store
 *
 * Accessor for `updateVariables` in the  VariablesStoreContext typeParam param patch export const updateVariables = function * < TVariables > ( patch ) { ( yield * getContext < UpdateVariablesFn < TVariables > > ( "updateVariables" ) ) ( patch ) ; } ; typeParam param defaultVariables returns A variable store context  VariablesStoreContext export const createVariableStore = < TVariables > ( defaultVariables ) : VariablesStoreContext < TVariables > => { let state = defaultVariables ; return { getVariable : selector => selector ( state ) , updateVariables : patch => { state = { ... state , ... patch } ; } } ; } ;