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

Function trigger

tech-study.js:903–923  ·  view source on GitHub ↗

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

(target, key, newVal, oldVal)

Source from the content-addressed store, hash-verified

901 * @returns
902 */
903function trigger(target, key, newVal, oldVal) {
904 // proxy
905 const proxyTarget = proxyMap.get(target);
906 if (!proxyTarget) {
907 return;
908 }
909 // proxyTarget 订阅列表
910 const subList = subscription.get(target);
911 if (!subList) {
912 return;
913 }
914 // 键订阅
915 let subkeyList = subList.get(key);
916 if (!subkeyList) {
917 return;
918 }
919 // 通知订阅
920 for (const fn of subkeyList) {
921 fn(newVal, oldVal);
922 }
923}
924/**
925 * @description 只读键
926 */

Callers 1

createSettersFunction · 0.70

Calls 1

getMethod · 0.45

Tested by

no test coverage detected