TabView缓存或重新加载策略

时间:2018-09-28 18:25:40

标签: angular2-nativescript nativescript-angular

我遇到了以下行为,并试图了解TabViewItem内容的缓存和加载如何以nativescript角度工作。

我有几个TabViewItems(A,B,C,D)。我在通过角度服务访问的全局dto对象中有一个属性,在选项卡B中将其称为“ propertyA”,在选项卡C中将其称为相同的属性。我在选项卡C中更改了属性,并且该属性在选项卡B中已正确更新。更改选项卡B中的属性,我单击选项卡C,属性在选项卡C中更新。奇怪的是,如果我单击选项卡A,然后单击选项卡C,则属性 IS 已更新。

通过console.log语句,当我单击选项卡B时似乎加载了选项卡C的内容,并且我假定当我从选项卡B中单击选项卡C时它们未加载的内容。而我假设当我单击选项卡A和然后使用标签C强制重新加载。

我看不到这将如何影响我的实际应用程序,因此我会暂时搁置它(严格的截止日期:)),但是如果有任何尝试的想法/解决方法,我将不胜感激。

亲切的问候, 托马斯。

注意:我无法发布整个项目,但这是我package.json的依赖项

  "dependencies": {
"@angular/animations": "~6.1.0",
"@angular/common": "~6.1.0",
"@angular/compiler": "~6.1.0",
"@angular/core": "~6.1.0",
"@angular/forms": "~6.1.0",
"@angular/http": "~6.1.0",
"@angular/platform-browser": "~6.1.0",
"@angular/platform-browser-dynamic": "~6.1.0",
"@angular/router": "~6.1.0",
"guid-typescript": "^1.0.7",
"lodash": "^4.17.11",
"nativescript-angular": "~6.1.0",
"nativescript-imagepicker": "~6.0.0",
"nativescript-plugin-firebase": "~6.0.0",
"nativescript-theme-core": "~1.0.4",
"nativescript-ui-listview": "~3.7.0",
"reflect-metadata": "~0.1.10",
"rxjs": "~6.2.0",
"tns-core-modules": "~4.2.0",
"zone.js": "~0.8.18"},

1 个答案:

答案 0 :(得分:0)

重要的是要知道组件lifecycle的角度如何破坏元素并使用缓存的元素。 但是,如果您想在所有选项卡中更新“ PropertyA”后立即在所有选项卡中对其进行更新,则可以创建观察者并在每个选项卡中订阅该观察器,而不是共享的全局对象