7
내 질문에 관련된 상점에서 파견하기 위해 가게와 ngOnInit에 선택하기 위해 생성자를 사용.ngrx 저장소에서</strong>을 선택</strong> & <strong>파견 <strong>에
의 공식 예제 응용 프로그램에서 다음 코드를 살펴 보자 :
export class CollectionPageComponent implements OnInit {
books$: Observable<Book[]>;
constructor(private store: Store<fromBooks.State>) {
this.books$ = store.select(fromBooks.getBookCollection);
}
ngOnInit() {
this.store.dispatch(new collection.Load());
}
}
나는 constructor
에서 ngOnInit
및 선택에서 파견 의 선택 동기를 이해하고 싶습니다.
누구든지 설명을 제공해 주시겠습니까?
P. 그건 그렇고, 위의 ngrx 예제 애플 리케이션에서 샘플 코드는 여기에 찾을 수 있습니다 : https://github.com/ngrx/platform/blob/master/example-app/app/books/containers/collection-page.ts
무엇이 당신을 혼란스럽게합니까? 무언가를하는 많은 방법이 있습니다. 이것은 잘못된 방법이 아닙니다.당신은 해결사, 또는 귀하의 응용 프로그램이 시작되는 순간부터 또는 다른 많은 방법으로 시작 http를 폴링과 같은 할 수 ... – notANerdDev