UNPKG

react-model

Version:

The State management library for React

44 lines (38 loc) 917 B
const State = {} const mutableState = {} const Actions = {} const AsyncState = {} const Middlewares = {} // Communicate between Provider-Consumer and Hooks const Setter: Setter = { // classSetter stores the setState from Provider // Invoke the classSetter.setState can update the state of Global Provider. classSetter: undefined, // functionSetter stores the setState returned by useStore. // These setStates can invoke the rerender of hooks components. functionSetter: {} } const Context = { __global: {} } const subscriptions = {} let devTools: any let withDevTools = false let uid = 0 // The unique id of hooks let storeId = 0 // The unique id of stores let currentStoreId = '0' // Used for useModel export default { Actions, AsyncState, Context, Middlewares, Setter, State, devTools, subscriptions, mutableState, uid, storeId, currentStoreId, withDevTools } as Global