Issue
Is it possible to define an expectation for a datatype in commonMain and then provide the actual datatype in jvmMain or jsMain?
for example lets say I wanted to use the local datatypes for Date in both JavaScript and Java in a commonMain class:
// commonMain
expect datatype Date
// jsMain
actual datatype Date = Date()
// jvmMain
actual datatype Date = LocalDate()
is such a thing possible? if so what does the syntax look like?
Solution
They are basically classes. So here is the syntax
//commonMain [Date.kt]
expect class Date
//jsMain [Date.kt]
actual typealias Date = kotlin.js.Date //this one implements the js date
//jvmMain [Date.kt]
actual typealias Date = java.util.Date //or you can use the java.time.LocalDateTime
hope this helps
Answered By - andylamax
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.