Repository navigation
Moves to @sjvair/sdk 4.7.0 and cancels requests that a newer selection has superseded (#124).
Changes
-
@sjvair/sdk4.7.0:- On same-origin browser writes, the SDK now adds
X-CSRFTokenfrom thecsrftokencookie. This lets the subscribe button keep working once sjvair.com's API starts checking CSRF on session-authenticated writes. - The subscribe button no longer sends an empty token. The request on the wire is unchanged.
- On same-origin browser writes, the SDK now adds
-
Cancelled requests: selecting a different monitor, pollutant or chart date range now cancels the request still in flight, instead of fetching it in full and dropping it.
- This covers the detail panel, the chart, the subscription status, and
monitorsManager.update(polling and pollutant switches). - Closing the panel cancels its chart request.
- Cancelled work is silent: no error state and no console output.
- This covers the detail panel, the chart, the subscription status, and
-
Managers accept
{ signal }: the following now take an optionalAbortSignal:monitorsManager.init(in its options) andmonitorsManager.updatecollocationSitesManager.initandcollocationSitesManager.updatehmsManager.init,hmsManager.loadSmokeandhmsManager.loadFireevStationsManager.loadLvl2StationsandevStationsManager.loadLvl3Stations
What a signal does:
- Aborting rejects the call with the signal's reason.
- An already-aborted signal rejects without sending a request.
- A call that would do nothing anyway (
update()before init,init()once initialized) resolves as before.
-
Shared
monitorsManager.init: when several callers share one load, a caller that aborts only stops its own wait. The load is cancelled only when every waiting caller has aborted, so a caller that passes no signal is never affected.
Upgrading
- If your app also depends on
@sjvair/sdkdirectly, move it to^4.7.0at the same time. Otherwise npm may install a second SDK copy under monitor-map, and that copy ignores your app'ssetOrigin. - Otherwise no changes are required. Calls without a signal behave as in 4.2.0, and the new
{ signal }options are optional. - monitor-map never calls the SDK's
setRequestDefaults; those page-wide defaults are left to your app.