0

Link to Doc: https://bixbydevelopers.com/dev/docs/reference/JavaScriptAPI/types

In essence, I can't understand the jargon. I feel it is too vague. I don't understand whether it creates new primitive type or is the module there to provide new value to existing primitive type (which as mentioned, an extension or contextualization of the "Output Type") ?

1 Answers1

4

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;
}
  • how does extend work? Because I was playing with it today and realized when defining a structure you list property with their custom types. So why is there a need for extend? – Nilay Patel Nov 24 '19 at 21:37