The @CanHandleSessionEndedRequest method decorator is used on the canHandle
method of a RequestHandler
class.
@CanHandleSessionEndedRequest(): (target: any, key: string, descriptor: PropertyDescriptor) => PropertyDescriptor
This decorator accepts the following parameters:
@CanHandleSessionEndedRequest()
No parameters passed to the decorator.
import { HandlerInput, RequestHandler } from 'ask-sdk';
import { Response } from 'ask-sdk-model';
import { CanHandleSessionEndedRequest } from 'ask-community-decorators';
export class SessionEndedRequestHandler implements RequestHandler {
@CanHandleSessionEndedRequest()
canHandle(handlerInput: HandlerInput): boolean {
// original code
return true;
}
}
is equivalent to
import { HandlerInput, RequestHandler } from 'ask-sdk';
import { Response } from 'ask-sdk-model';
export class SessionEndedRequestHandler implements RequestHandler {
canHandle(handlerInput: HandlerInput): boolean {
// decorator code
const canHandle = handlerInput.requestEnvelope.request.type === 'SessionEndedRequest';
if (canHandle === false) {
return false;
}
// original code
return true;
}
}