ng-universal-demo icon indicating copy to clipboard operation
ng-universal-demo copied to clipboard

onBootstrap

Open paulogr opened this issue 7 years ago • 1 comments

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!

paulogr avatar Jun 07 '17 18:06 paulogr

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

FrozenPandaz avatar Jun 10 '17 19:06 FrozenPandaz