Skip to content
This repository has been archived by the owner on Oct 31, 2022. It is now read-only.

Refresh

maxSS edited this page Sep 13, 2019 · 5 revisions
import { JamRefreshModule } from 'ngx-jsonapi-material';

Selector: jam-refresh

Properties
Name Value type Required Description
@Input() serviceToRefresh Service true
@Input() collectionToRefresh Collection true

Should be added in both HTML and TS files

<jam-refresh
    [serviceToRefresh]="someService"
    [collectionToRefresh]="someCollection"
></jam-refresh>
import { JamRefreshService, Destroyer } from 'ngx-jsonapi-material';

public destroyer = new Destroyer();

public constructor(public jamRefreshService: JamRefreshService) {}

public ngOnInit() {
    this.jamRefreshService.refreshSubject
        .pipe(this.destroyer.pipe()) // IMPORTANT: remember to unsubscribe in OnDestroy lifecycle hook
        .subscribe(
            () => {
                this.someCollection = this.getNewCollectionFromServer(this.filter); // NOTE: code needed to reload the collection
            }
        );
}

public ngOnDestroy() {
    this.destroyer.destroy();
}
Clone this wiki locally