This repository has been archived by the owner on Oct 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Refresh
maxSS edited this page Sep 13, 2019
·
5 revisions
import { JamRefreshModule } from 'ngx-jsonapi-material';
Selector: jam-refresh
Name | Value type | Required | Description |
---|---|---|---|
@Input() serviceToRefresh |
Service |
true |
|
@Input() collectionToRefresh |
Collection |
true |
<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();
}