resetIntl
resetIntl() destroys and removes the package default runtime.
This is the cleanest reset strategy for tests, demos, and repeated bootstraps in the same process.
ts
1import { initIntl, resetIntl, getIntl } from '@beforesemicolon/intl'2 3initIntl({ locale: 'en-US', messages: { hello: 'Hello' } })4resetIntl()5getIntl().locale // resolves to the package default initial locale logicSignature
ts
1function resetIntl(): voidWhat gets cleared
- default runtime object
- listeners and subscriptions tied to the default runtime
- loaded messages and in-flight locale loads for the default runtime
- runtime caches (
formatterCacheandmessageCache)
It does not remove any custom scoped runtimes you created explicitly.
resetIntl() vs destroyIntl()
destroyIntl(scope)targets a specific runtime.resetIntl()always targets and removes only the default runtime.
ts
1import { createIntl, destroyIntl, resetIntl } from '@beforesemicolon/intl'2 3const widgetRuntime = createIntl({ locale: 'en-US' })4destroyIntl(widgetRuntime) // scoped teardown5resetIntl() // default teardownCommon test setup
ts
1beforeEach(() => {2 resetIntl()3})4 5afterEach(() => {6 resetIntl()7})