(
graphs: any,
paths: any,
id: any,
prop: any,
changeType?: any,
withPriority = true
)
| 42 | `${stringifyId(id)}.${property}`; |
| 43 | |
| 44 | export function getCallbacksByInput( |
| 45 | graphs: any, |
| 46 | paths: any, |
| 47 | id: any, |
| 48 | prop: any, |
| 49 | changeType?: any, |
| 50 | withPriority = true |
| 51 | ): ICallback[] { |
| 52 | const matches: ICallback[] = []; |
| 53 | const idAndProp = combineIdAndProp({id, property: prop}); |
| 54 | |
| 55 | if (typeof id === 'string') { |
| 56 | // standard id version |
| 57 | const callbacks = (graphs.inputMap[id] || {})[prop]; |
| 58 | if (!callbacks) { |
| 59 | return []; |
| 60 | } |
| 61 | |
| 62 | callbacks.forEach( |
| 63 | addAllResolvedFromOutputs(resolveDeps(), paths, matches) |
| 64 | ); |
| 65 | } else { |
| 66 | // wildcard version |
| 67 | const _keys = Object.keys(id).sort(); |
| 68 | const vals = props(_keys, id); |
| 69 | const keyStr = _keys.join(','); |
| 70 | const patterns: any[] = (graphs.inputPatterns[keyStr] || {})[prop]; |
| 71 | if (!patterns) { |
| 72 | return []; |
| 73 | } |
| 74 | patterns.forEach(pattern => { |
| 75 | if (idMatch(_keys, vals, pattern.values)) { |
| 76 | // When a callback's Outputs have no MATCH keys, the |
| 77 | // triggering Input's MATCH values are what uniquify each |
| 78 | // firing's resolvedId (see addAllResolvedFromOutputs). |
| 79 | // Callbacks whose Outputs do carry MATCH keys ignore this |
| 80 | // value since the Output pattern drives resolution. |
| 81 | const triggerAnyVals = getAnyVals(pattern.values, vals); |
| 82 | pattern.callbacks.forEach( |
| 83 | addAllResolvedFromOutputs( |
| 84 | resolveDeps(_keys, vals, pattern.values), |
| 85 | paths, |
| 86 | matches, |
| 87 | triggerAnyVals |
| 88 | ) |
| 89 | ); |
| 90 | } |
| 91 | }); |
| 92 | } |
| 93 | matches.forEach(match => { |
| 94 | match.changedPropIds[idAndProp] = changeType || DIRECT; |
| 95 | if (withPriority) { |
| 96 | match.priority = getPriority(graphs, paths, match); |
| 97 | } |
| 98 | }); |
| 99 | return matches; |
| 100 | } |
| 101 |
no test coverage detected
searching dependent graphs…