I am creating an ng2 application using ngrx. When the application starts, the web service is called to get the source data, after receiving this data, I create the INIT_DONE action.
My condition is as follows:
export interface State { documents: Document[]; selectedDocument: Document }
When I go to the / mypage / 456 page, where 456 is the url parameter, I need to get some of the data received, so I get the URL parameter as follows:
ngOnInit() { this.paramSubscription = this.route.params .select<string>('id') .map((id) => new SelectAction(id)) .subscribe(this.store); }
SELECT_ACTION finds the item in the extracted data and sets selectedDocument
. The problem is that SELECT_ACTION is created before INIT_DONE and at this point documents
empty.
How to wait for INIT_DONE before loading my page?
Mario source share