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

Function trackRef

tech-study.js:799–830  ·  view source on GitHub ↗
(target)

Source from the content-addressed store, hash-verified

797 * @param key
798 */
799const trackRef = (target) => {
800 // 当前订阅
801 if (!currentSub) {
802 return;
803 }
804 // target 订阅列表
805 let subList = subscription.get(target);
806 // 不存在订阅列表
807 if (!subList) {
808 subList = new Map();
809 // 键订阅
810 const subkeyList = new Set();
811 // 添加订阅
812 subkeyList.add(currentSub);
813 subList.set('value', subkeyList);
814 subscription.set(target, subList);
815 return;
816 }
817 // 键订阅
818 let subkeyList = subList.get('value');
819 if (!subkeyList) {
820 // 键订阅
821 subkeyList = new Set();
822 // 添加订阅
823 subkeyList.add(currentSub);
824 subList.set('value', subkeyList);
825 subscription.set(target, subList);
826 return;
827 }
828 // 添加订阅
829 subkeyList.add(currentSub);
830};
831/**
832 * @description 通知 Ref 订阅
833 * @param terget

Callers 2

getMethod · 0.70
watchFunction · 0.70

Calls 2

getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected