evertonrobertoauler / universal-demo-v5

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TransferState issue

damandeep81 opened this issue · comments

Hi Everton,

You have written a very nice and easy to understand way for this tutorial. I am having a small issue while running my app on production server. I have used the transferstate to stop sending my calls twice. It fires the calls for the first time to my api and once I come back to the page thru which that api call hits will not show the page correctly as data is not setted to the object which i used in my component.

Here is the code scenario:

const HOME_KEY = makeStateKey('homeWidgetList') public homeWidgetList:any; ngOnInit() { this.homeWidgetList = this.tstate.get(HOME_KEY, null as any); if (!this.homeWidgetList) { this.homeWidgetList = this.homeService.getHomeWidgetList().then(res=>{ this.homeWidgetList = res; this.widgetLoader = false; this.tstate.set(HOME_KEY, res as any); }); }

Here tstate is "private tstate: TransferState" defined in the constructor.

Waiting for your help regarding same.