diff --git a/js/directions.js b/js/directions.js index 11d2d34..5e29746 100644 --- a/js/directions.js +++ b/js/directions.js @@ -105,13 +105,12 @@ export function createDirections({ key, consent = () => false, maps = loadMaps, const ready = () => (consent() && globalThis.navigator?.onLine !== false ? maps(key, doc) : Promise.reject(new Error('unavailable'))); return { - // Bumped by the caller whenever the origin or the date moves. A response - // that comes back against an old generation is dropped rather than - // rendered, which is the rule docs/research/walking-routes-115.md sets: a - // stale answer must never reorder or relabel a list already on screen. - get generation() { - return generation; - }, + // Bumped by the caller whenever the origin or the date moves, and handed + // back so the caller can tell generations apart without this object + // keeping a second, readable copy of the count. A response that comes + // back against an old generation is dropped rather than rendered, which + // is the rule docs/research/walking-routes-115.md sets: a stale answer + // must never reorder or relabel a list already on screen. invalidate() { generation += 1; return generation; diff --git a/scripts/test/directions.test.mjs b/scripts/test/directions.test.mjs index 1b75f33..7443bc5 100644 --- a/scripts/test/directions.test.mjs +++ b/scripts/test/directions.test.mjs @@ -139,10 +139,8 @@ test('an answer against an old generation is dropped', async () => { test('invalidate counts up so a caller can tell generations apart', () => { const { maps } = fakeMaps({ leg: LEG }); const d = createDirections({ key: 'k', consent: yes, maps }); - assert.equal(d.generation, 0); assert.equal(d.invalidate(), 1); assert.equal(d.invalidate(), 2); - assert.equal(d.generation, 2); }); // --- the matrix, all or nothing