Commit fd16d98
committed
Run debounce callback if browser tab is closed
A common issue with debounced API calls is that when the user closes the
browser tab, the debounced function may not have run yet. This is a
frequent cause of data loss. The debounce implementation now prevents
this issue by running the trailing debounce immediately if the tab is
closed prior to the trailing timeout.
The code detects whether it's running in an environment with access to
`document.addEventListener()`. In runtimes where this function is
unavailable (e.g. Node.js) the new functionality is ignored since would
not be relevant in that context.1 parent d122213 commit fd16d98
File tree
9 files changed
+120
-15
lines changed- docs
- modules
- modules
9 files changed
+120
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
866 | 866 | | |
867 | 867 | | |
868 | 868 | | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
869 | 878 | | |
870 | 879 | | |
871 | 880 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2933 | 2933 | | |
2934 | 2934 | | |
2935 | 2935 | | |
| 2936 | + | |
| 2937 | + | |
| 2938 | + | |
| 2939 | + | |
| 2940 | + | |
| 2941 | + | |
| 2942 | + | |
| 2943 | + | |
2936 | 2944 | | |
2937 | 2945 | | |
2938 | 2946 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
8 | 18 | | |
9 | 19 | | |
10 | 20 | | |
11 | 21 | | |
12 | 22 | | |
13 | | - | |
14 | | - | |
15 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
16 | 31 | | |
17 | 32 | | |
18 | 33 | | |
19 | 34 | | |
| 35 | + | |
| 36 | + | |
20 | 37 | | |
21 | 38 | | |
22 | 39 | | |
| |||
26 | 43 | | |
27 | 44 | | |
28 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
29 | 51 | | |
30 | 52 | | |
31 | 53 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1134 | 1134 | | |
1135 | 1135 | | |
1136 | 1136 | | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
1137 | 1147 | | |
1138 | 1148 | | |
1139 | 1149 | | |
1140 | 1150 | | |
1141 | 1151 | | |
1142 | | - | |
1143 | | - | |
1144 | | - | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
1145 | 1160 | | |
1146 | 1161 | | |
1147 | 1162 | | |
1148 | 1163 | | |
| 1164 | + | |
| 1165 | + | |
1149 | 1166 | | |
1150 | 1167 | | |
1151 | 1168 | | |
| |||
1155 | 1172 | | |
1156 | 1173 | | |
1157 | 1174 | | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
1158 | 1180 | | |
1159 | 1181 | | |
1160 | 1182 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments