Skip to main content
Version: 5.x.x

Core Events

Tolgee events which can be listened through tolgee.on method.

language

Emitted on language change.

tolgee.on('language', handler: ListenerHandler<string>)

pendingLanguage

Emitted on language change. Before languages are loaded (when tolgee is running).

tolgee.on('pendingLanguage', handler: ListenerHandler<string>)

loading

Emitted on loading change. Changes when tolgee is loading some data for the first time.

tolgee.on('loading', handler: ListenerHandler<boolean>)

fetching

Emitted on fetching change. Changes when tolgee is fetching any data.

tolgee.on('fetching', handler: ListenerHandler<boolean>)

initialLoad

Emitted when run method finishes.

tolgee.on('initialLoad', handler: ListenerHandler<void>)

running

Emitted when internal running state changes.

tolgee.on('initialLoad', handler: ListenerHandler<boolean>)

cache

Emitted when cache changes.

tolgee.on('cache', handler: ListenerHandler<CacheDescriptorWithKey>)

update

Emitted when any key needs (or might need) to be re-rendered. Similar to tolgee.onNsUpdate, except we intercept all events, not just selection.

tolgee.on('update', handler: ListenerHandler<void>)

error

Emitted when there is an error. You can intercept different types of errors, connected to fetching language data, detecting language or loading/storing language, you can filter them by name property on the error, which can be:

  • RecordFetchError - error when fetching translations record, you can also read language and namespace properties, to see which record has failed
  • LanguageDetectorError - error when detecting language through language detector plugin
  • LanguageStorageError - error when loading/saving language through language storage plugin
tolgee.on('error', handler: ListenerHandler<TolgeeError>)