MCPcopy Create free account
hub / github.com/Xu22Web/tech-study-js / triggerRef

Function triggerRef

tech-study.js:837–854  ·  view source on GitHub ↗

* @description 通知 Ref 订阅 * @param terget * @param key * @returns

(target, newVal, oldVal)

Source from the content-addressed store, hash-verified

835 * @returns
836 */
837function triggerRef(target, newVal, oldVal) {
838 // target 订阅列表
839 const subList = subscription.get(target);
840 if (!subList) {
841 return;
842 }
843 // 键订阅
844 let subkeyList = subList.get('value');
845 if (!subkeyList) {
846 return;
847 }
848 // 通知订阅
849 for (const fn of subkeyList) {
850 if (fn instanceof Function) {
851 fn(newVal, oldVal);
852 }
853 }
854}
855/**
856 * @description 收集依赖
857 * @param target

Callers 1

setMethod · 0.70

Calls 1

getMethod · 0.45

Tested by

no test coverage detected