This function does Bixby-specific type coercion in JavaScript, similar to $expr()
in EL. You could have an action declared like this:
action (FindTicket) {
output (event.Ticket)
}
You might want the JavaScript implementation for this action to be able to return more specific types than just event.Ticket
. Suppose it can return both event.MovieTicket
and event.ConcertTicket
, which both extend
the event.Ticket
concept. If your JS code has the event.Ticket
data, it could turn that into one of the other specific types when it returns the value:
if (ticket.type == 'movie') {
return types.TypedValue(ticket, "event.MovieTicket", ticket.id);
else if (ticket.type == 'concert') {
return types.TypedValue(ticket, "event.ConcertTicket", ticket.id);
else {
// the "ticket" object is already an event.Ticket, and can be returned directly
return ticket;
}