Get an UndefinedBehaviorError when using a parameter of type case class in an scalajs method which I handover from a play framework Scala/Twirl template view/notify.scala.html:
@(note: Notification, ...)(implicit ...)
<!DOCTYPE html>
<html>
<body>
...
<script type="text/javascript" charset="utf-8">
CommandsJS.notify('@note');
</script>
</body>
</html>
Here the case classes:
abstract class Notification
case class Email(sender: String, title: String, body: String) extends Notification
case class SMS(caller: String, message: String) extends Notification
and the method defined in ScalaJs:
@JSExport
def notify(notification: Notification): Unit = {
...
notification match {
case Email(email, title, _ ) => log.info(s"Email: $email")
case SMS(number, message) => log.info(s"SMS: $number")
}
}
The case class gets instantiated in the controller:
class AppCtrl ... {
def sendNote = silhouette.UserAwareAction { implicit request =>
Ok(views.html.notify(SMS("John","hi John"), ...))
}
}
Get runtime error within javascript console: An undefined behavior was detected: SMS(John,hi John) is not an instance of Notification. Any help/workaround appreciated - thanks