Skip to content

v4.3.0

Latest

Choose a tag to compare

@alexandermccormick alexandermccormick released this 21 Oct 22:18
· 2 commits to main since this release
18acf25

Moves to @sjvair/sdk 4.7.0 and cancels requests that a newer selection has superseded (#124).

Changes

  • @sjvair/sdk 4.7.0:

    • On same-origin browser writes, the SDK now adds X-CSRFToken from the csrftoken cookie. 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.
  • 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.
  • Managers accept { signal }: the following now take an optional AbortSignal:

    • monitorsManager.init (in its options) and monitorsManager.update
    • collocationSitesManager.init and collocationSitesManager.update
    • hmsManager.init, hmsManager.loadSmoke and hmsManager.loadFire
    • evStationsManager.loadLvl2Stations and evStationsManager.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/sdk directly, move it to ^4.7.0 at the same time. Otherwise npm may install a second SDK copy under monitor-map, and that copy ignores your app's setOrigin.
  • 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.