Commit a61cf14
committed
Add source-of-truth loading state methods (v1.0.12)
The root issue: isLoading flag gets out of sync with actual in-flight requests,
especially with reactive frameworks calling .it() multiple times.
Solution: Provide direct access to the source of truth - the in-flight request map.
New Public API Methods:
- isItemLoading(typeName, id, level): Check if specific item is loading
- hasAnyInFlightRequests(): Check if ANY requests are in-flight
Key Changes:
1. Added isItemLoading() to check G.inFlightItm map directly
2. Added hasAnyInFlightRequests() for global loading state
3. Updated fetchItem() to sync isLoading with actual in-flight state
4. Added in-flight counts to devtools snapshot
5. Exported both methods in public API
6. Documented usage patterns and examples
Why This Fixes the Bug:
Instead of relying on state flags (isLoading) that can desync during reactive
cycles, developers can now query the actual in-flight request map. This is the
single source of truth that can't get out of sync.
Usage Pattern (Alpine.js):
get isLoadingAuth() {
return DL.isItemLoading('me', 'current') // Always accurate!
}
DevTools Support:
const snapshot = DL.devtools()
snapshot.inFlight.totalCount // Number of in-flight requests
snapshot.inFlight.hasAnyInFlight // Boolean
snapshot.inFlight.items // Array of in-flight items
snapshot.inFlight.collections // Array of in-flight collections
Version: 1.0.11 → 1.0.121 parent 3e7d1a7 commit a61cf14
2 files changed
Lines changed: 142 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1028 | 1028 | | |
1029 | 1029 | | |
1030 | 1030 | | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
1031 | 1148 | | |
1032 | 1149 | | |
1033 | 1150 | | |
| |||
1040 | 1157 | | |
1041 | 1158 | | |
1042 | 1159 | | |
| 1160 | + | |
| 1161 | + | |
1043 | 1162 | | |
1044 | 1163 | | |
1045 | 1164 | | |
1046 | 1165 | | |
| 1166 | + | |
1047 | 1167 | | |
1048 | 1168 | | |
1049 | 1169 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1236 | 1236 | | |
1237 | 1237 | | |
1238 | 1238 | | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
1239 | 1248 | | |
1240 | 1249 | | |
1241 | 1250 | | |
| |||
1698 | 1707 | | |
1699 | 1708 | | |
1700 | 1709 | | |
1701 | | - | |
1702 | 1710 | | |
| 1711 | + | |
| 1712 | + | |
| 1713 | + | |
| 1714 | + | |
| 1715 | + | |
| 1716 | + | |
| 1717 | + | |
1703 | 1718 | | |
1704 | 1719 | | |
1705 | 1720 | | |
| |||
2038 | 2053 | | |
2039 | 2054 | | |
2040 | 2055 | | |
| 2056 | + | |
| 2057 | + | |
2041 | 2058 | | |
2042 | 2059 | | |
2043 | 2060 | | |
| |||
2121 | 2138 | | |
2122 | 2139 | | |
2123 | 2140 | | |
| 2141 | + | |
| 2142 | + | |
2124 | 2143 | | |
2125 | 2144 | | |
2126 | 2145 | | |
| |||
2144 | 2163 | | |
2145 | 2164 | | |
2146 | 2165 | | |
| 2166 | + | |
| 2167 | + | |
2147 | 2168 | | |
2148 | 2169 | | |
2149 | 2170 | | |
| |||
0 commit comments