Webapi with Hub-Cleanup Assistance Pattern
any of the index key should be registerForCleanup. i.e. any of indexXxx should follow the registerForCleanup.
clean the indexed key which indexed by the host component in beforeUnmount. And so that the component doesn't clean the key that doesn't create by the component itself.
The hub is not a second, redundant path that would make this web-api cleanup a mere demonstration.
Common/CleanupHub.cs keeps its key registry in an ordinary instance property, and SignalR builds a
fresh hub instance for every invocation, so the entry Add records is discarded with the instance
that received it and OnDisconnectedAsync always walks an empty registry. The index-remove calls
wwwroot-src/src/composables/useCleanupHub.ts makes — on unmount and on every key replacement — are
the only ones that actually free a key, which is why registering a key without releasing it there
leaks it for the life of the process.
Notice
- before current key modified, the previous key should be called this.cleanupKey.
- A twin key should be made from the outside key to keep the lifecycle maintained.