feat: add minimal reactive store linkage for ArkTS shell
This commit is contained in:
1 parent
0b20b5dd43
commit
7fb4e6117a
8 files changed
+147
-6
No files matched your search
@@ -9,18 +9,33 @@ import { AppListView } from '../components/appList/AppListView'
|
||||
@Entry
|
||||
@Component
|
||||
struct AppListPage {
|
||||
@State refreshTick: number = 0
|
||||
private store: AppCatalogStore = new AppCatalogStore()
|
||||
private unsubscribe?: () => void
|
||||
|
||||
aboutToAppear(): void {
|
||||
if (!this.unsubscribe) {
|
||||
this.unsubscribe = this.store.subscribe(() => {
|
||||
this.refreshTick += 1
|
||||
})
|
||||
}
|
||||
this.store.loadApps()
|
||||
}
|
||||
|
||||
aboutToDisappear(): void {
|
||||
if (this.unsubscribe) {
|
||||
this.unsubscribe()
|
||||
this.unsubscribe = undefined
|
||||
}
|
||||
}
|
||||
|
||||
private openImportPage(): void {
|
||||
console.info('TODO: open ImportPage')
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Text(`${this.refreshTick}`).fontSize(1).opacity(0)
|
||||
PageHeader({ title: '应用列表' })
|
||||
if (this.store.error) {
|
||||
StatusBanner({ text: this.store.error.message })
|
||||
|
||||
Reference in new issue
Block a user