Skip to content

v0.52.0

Pre-release
Pre-release

Choose a tag to compare

@yhdgms1 yhdgms1 released this 28 Jun 16:56
· 14 commits to main since this release
ad13bcf

Clean up

Custom actions provide clear function in which you can register cleanup handler. Previously you could register only one cleanup handler, now it is possible to register multiple. Cleanup handlers will be called in reverse order.

Code
const handler: CustomHandler = async ({ clear, paused }) => {
  const unsubscribe = paused.subscribe((paused) => {
    // do something there
  })

  // called last
  clear(unsubscribe);

  clear(() => console.log('I was called second'))
  clear(() => console.log('I was called first'))
}

Changed logic on how these cleanup handlers are stored. Now for every custom action there is created a spot in which cleanup handlers are saved. When back button is pressed, engine compares actions that are present now with actions that present then, and cleans up actions in the difference.

Explanation

Each number in array represents each custom action called

a: [1, 2, 3, 4]
b: [1, 2, 3, 4, 5]
c: [1, 2, 3, 4, 5, 6]

When I want to go back from c to b I take the difference between [1, 2, 3, 4, 5, 6] and [1, 2, 3, 4, 5] which is 6.
Same thing with b to a, difference is 5.

We try not to call actions 1, 2, 3 and 4 because they are running already.

When there is no left actions with same id and key we remove custom action's node from DOM.

Clean up is called when exit button is clicked.

Clean up is NOT called after custom action is called. In case it has requiresUserAction property and returns promise, cleanup should be done manually.

Here be dragons but I think that works.

Storage

The localStorageStorage was renamed to storageAdapterLocal.