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

Function track

tech-study.js:860–896  ·  view source on GitHub ↗
(target, key)

Source from the content-addressed store, hash-verified

858 * @param key
859 */
860const track = (target, key) => {
861 // 当前订阅
862 if (!currentSub) {
863 return;
864 }
865 // proxy
866 const proxyTarget = proxyMap.get(target);
867 if (!proxyTarget) {
868 return;
869 }
870 // target 订阅列表
871 let subList = subscription.get(target);
872 // 不存在订阅列表
873 if (!subList) {
874 subList = new Map();
875 // 键订阅
876 const subkeyList = new Set();
877 // 添加订阅
878 subkeyList.add(currentSub);
879 subList.set(key, subkeyList);
880 subscription.set(target, subList);
881 return;
882 }
883 // 键订阅
884 let subkeyList = subList.get(key);
885 if (!subkeyList) {
886 // 键订阅
887 subkeyList = new Set();
888 // 添加订阅
889 subkeyList.add(currentSub);
890 subList.set(key, subkeyList);
891 subscription.set(target, subList);
892 return;
893 }
894 // 添加订阅
895 subkeyList.add(currentSub);
896};
897/**
898 * @description 通知订阅
899 * @param terget

Callers 1

createGettersFunction · 0.70

Calls 2

getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected