Closed adrianmarinica closed 5 years ago
Hello @adrianmarinica It is still supported, but I would recommend to use observable method and unsubscribe if you need to cancel the request.
ex:
@Injectable()
@ResourceParams({
.... your options
})
export class MyResource extends Resource {
@ResourceAction({
.... your options
})
someMethod$: IResourceMethodObservable<any, any>;
}
// component
export class MyComponent implements OnInit, OnDestroy {
data: any = null;
private subscription: Subscription | null = null;
constructor(private myResource: MyResource) {}
ngOnInit() {
this.subscription = this.myResource.someMethod$.subscribe(data => {
this.data = data;
this.subscription = null;
})
}
ngOnDestroy() {
if (this.subscription) {
this.subscription.unsubscribe();
this.subscription = null;
}
}
}
Thanks for the help and for the code sample!
What would be the recommended way to abort a request with the 7.0 functionality? I found an
abort
method in theIResourceHandlerResponse
interface, but I can't seem to find the necessary objects to use it. The only object of this type is the result of thehandle
method in theResourceHandler
object, but thishandle
method requires anIResourceRequest
object that I have no idea where to get.Is this still a supported functionality? Thanks!