1
0
mirror of https://github.com/Qortal/qortal-ui.git synced 2025-08-16 07:31:38 +00:00
Files
build
config
core
assets
config
emoji
exports
font
language
memory-pow
public
server
sound
src
tooling
translate
directives
lang-changed-base.js
lang-changed.js
translate-unsafe-html.js
translate.js
config.js
helpers.js
index.js
model.js
util.js
.eslintignore
.eslintrc.json
ui-core.js
crypto
img
lib
locales
plugins
scripts
snap
splash
.editorconfig
.eslintignore
.eslintrc.json
.gitattributes
.gitignore
.travis.yml
CONTRIBUTING.md
LICENSE
README.md
blog-test.json
build-setup.js
build.bat
build.js
build.sh
electron-builder.yml
electron.js
install-dependencies.sh
package-lock.json
package.json
push-updates-with-travis-build.sh
run_server.bat
server.js
set-up-snap.sh
watch-inline.js
watch.js
qortal-ui/core/translate/directives/lang-changed-base.js
2023-11-25 16:25:19 +01:00

40 lines
915 B
JavaScript

import { AsyncDirective } from 'lit/async-directive.js'
import { listenForLangChanged } from '../util.js'
export class LangChangedDirectiveBase extends AsyncDirective {
constructor() {
super(...arguments)
this.langChangedSubscription = null
this.getValue = (() => "")
}
renderValue(getValue) {
this.getValue = getValue
this.subscribe()
return this.getValue()
}
langChanged(e) {
this.setValue(this.getValue(e))
}
subscribe() {
if (this.langChangedSubscription == null) {
this.langChangedSubscription = listenForLangChanged(this.langChanged.bind(this))
}
}
unsubscribe() {
if (this.langChangedSubscription != null) {
this.langChangedSubscription()
}
}
disconnected() {
this.unsubscribe()
}
reconnected() {
this.subscribe()
}
}