FrozenPandaz / ng-universal-demo

171 stars 54 forks source link

onBootstrap #17

Open paulogr opened 7 years ago

paulogr commented 7 years ago
export function onBootstrap(appRef: ApplicationRef, transferState: TransferState) {
  return () => {
    appRef.isStable
      .filter(stable => stable)
      .first()
      .subscribe(() => {
        transferState.inject();
      });
  };
}

Is this garanteed?

I have a medium-size angular application and I'm trying to apply the state transfer but my state is being injected before the backend calls...

Anyone had this problem? What can I doing wrong? Thank you!

FrozenPandaz commented 7 years ago

Not sure, if the data from your backend calls is in the transfer state it should be there by this point. This should be approximately right before the render happens. Note: the TransferState does not automatically pick up your backend data, you must use TransferHttp in place of Http