NativeConverter

@implicitNotFound("Could not find an implicit NativeConverter[${A}]")

Typeclass for converting between Scala.js and native JavaScript.

Type Params
A

the type to convert

Companion
object
class Object
trait Matchable
class Any

Value members

Abstract methods

def fromNativeE(ps: ParseState): Either[String, A]

Convert a native Javascript type to Scala.js. Returns either A, or a String error.

Convert a native Javascript type to Scala.js. Returns either A, or a String error.

Concrete methods

def fromJson(json: String): A

Convert a Json String to type A. Returns A, or throws.

Convert a Json String to type A. Returns A, or throws.

def fromJsonE(json: String): Either[String, A]

Convert a Json String to type A. Returns either A, or a String error.

Convert a Json String to type A. Returns either A, or a String error.

def fromNative(nativeJs: Any): A

Convert a native Javascript type to Scala.js. Returns A, or throws.

Convert a native Javascript type to Scala.js. Returns A, or throws.

def fromNativeE(nativeJs: Any): Either[String, A]

Convert a native Javascript type to Scala.js. Returns either A, or a String error.

Convert a native Javascript type to Scala.js. Returns either A, or a String error.

Extensions

Extensions

extension (a: A)
def toJson: String

Convert type A to a JSON string

Convert type A to a JSON string

def toNative: Any

Convert a Scala.js type to native JavaScript.

Convert a Scala.js type to native JavaScript.

This is an extension method, so it's available on all types that derive NativeConverter. To use for other types, like Int, summon a NativeConverter and use: NativeConverter[Int].toNative(123)