MCPcopy Index your code
hub / github.com/effector/effector / processCreateGateConfig

Function processCreateGateConfig

src/react/createGate.ts:89–128  ·  view source on GitHub ↗
(
  hook: typeof useGateBase,
  args: unknown[],
)

Source from the content-addressed store, hash-verified

87 isObject(arg) && (arg.and || arg.or)
88
89export function processCreateGateConfig<State>(
90 hook: typeof useGateBase,
91 args: unknown[],
92): {
93 domain?: Domain
94 defaultState: State | {}
95 hook: typeof useGateBase
96 mainConfig?: Record<string, any>
97 maybeConfig?: Record<string, any> & {sid?: string}
98} {
99 const universalConfig =
100 args && isStructuredConfig(args[0]) ? args : [{and: args}]
101 const [[nameOrConfig, defaultStateOrConfig], metadata] =
102 processArgsToConfig(universalConfig)
103
104 let domain
105 let defaultState = {}
106 let mainConfig = {}
107 let maybeConfig = metadata
108
109 if (typeof nameOrConfig === 'string') {
110 mainConfig = {name: nameOrConfig}
111 if (isPluginConfig(defaultStateOrConfig)) {
112 // maybeConfig = defaultStateOrConfig
113 } else {
114 defaultState = defaultStateOrConfig || {}
115 }
116 } else if (isGateConfig(nameOrConfig)) {
117 mainConfig = nameOrConfig
118 defaultState = nameOrConfig.defaultState || {}
119 domain = nameOrConfig.domain
120 }
121 return {
122 hook,
123 domain,
124 defaultState,
125 mainConfig,
126 maybeConfig,
127 }
128}
129
130export function createGate<Props>(...args: unknown[]): Gate<Props> {
131 return createGateImplementation<Props>(

Callers 2

createGateFunction · 0.90
createGateFunction · 0.85

Calls 4

processArgsToConfigFunction · 0.90
isStructuredConfigFunction · 0.70
isPluginConfigFunction · 0.70
isGateConfigFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…