Skip to content

Commit

Permalink
expose registry dispose & reset
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart committed Feb 5, 2024
1 parent fe01025 commit bd7f6ba
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/friendly-zoos-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect-rx/rx": patch
---

expose registry dispose & reset
2 changes: 2 additions & 0 deletions packages/rx/src/Registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export interface Registry {
readonly refresh: Rx.Rx.RefreshRxSync
readonly set: Rx.Rx.Set
readonly subscribe: Rx.Rx.Subscribe
readonly reset: () => void
readonly dispose: () => void
}

/**
Expand Down
9 changes: 6 additions & 3 deletions packages/rx/src/internal/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,19 @@ class RegistryImpl implements Registry.Registry {
})
}

dispose(): void {
this.disposed = true

reset(): void {
this.timeoutBuckets.forEach(([, handle]) => clearTimeout(handle))
this.timeoutBuckets.clear()
this.nodeTimeoutBucket.clear()

this.nodes.forEach((node) => node.remove())
this.nodes.clear()
}

dispose(): void {
this.disposed = true
this.reset()
}
}

const enum NodeFlags {
Expand Down

0 comments on commit bd7f6ba

Please sign in to comment.