現在、私はNgrxストアでAngularを学習しようとしています。サンプルを見て、私は次のことを思いついた。 (完全なソースhttps://github.com/sebfischer83/Cointo/tree/master/angular/src)Ngrxストアとデータのリロードを防止する方法
私は、ストアを含み、データベースからエンティティを読み込むコンテナコンポーネントを持っています。
@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
templateUrl: './materials-Page.component.html',
styleUrls: ['./materials-Page.component.css']
})
export class MaterialsPageComponent implements OnInit {
materials$: Observable<MaterialDto[]>;
constructor(private _store: Store<fromRoot.AppState>) {
this.materials$ = _store.select(fromRoot.getMaterialsEntities);
}
ngOnInit() {
this._store.dispatch(new LoadMaterialsAction());
}
しかし、多分私は理解して問題を抱えている私の店は、私はこのページをクリックするたびに更新されますので、今私はngOnInit
でこのコンポーネントにディスパッチを変更するたびに、サーバーからすべてのデータを再ロードします。しかし、店舗内に既に存在するデータは使用しないでください。