So....is there a Kotlin equivalent to System?
# multiplatform
a
So....is there a Kotlin equivalent to System?
b
In Multiplatform if you want access to system, you would need to use expect/actual and then for each target make a specific implementation of the functionality for that individual System.
a
k. Thanks!
b
Feel free to reach out for more info 🙂
a
[waving hand] This is not the answer I was looking for.....
🙂
Well, not what I was expecting
b
Sadly… I feel the same, a few months ago I had to create “File” representations for 3 targets
a
I'm in the same boat, but I'm using Korlabs korIO package
i
still early days, quite a few things are missing that are kind of critical near term like Date, Locale, File and general IO, knowing details about the host such as some of what System provides.
a
I don't know if it actually works. I'm still coding against it
b
I looked at theirs, I cant recall what about it that didn’t fit our usecase.
a
Lack of docs
😂 1
I have to read the test apps to figure out how to use it
Much less, understand what they do
But, I'm desparate
b
What functionality do you need?
a
I need to read properties files
for starters
I've completed the implementation with that lib, but now I'm facing the System issue
since I need to read the environment vars
But, perhaps I'll forego that aspect
b
If you need env… would it be better to handle that through gradle at compile time?
a
I need it at runtime, unfortunately
We have Java, Node and mobile platforms and I need to create a lib that works on all of them
I chose Kotlin because of "the promise", but I didn't realize that it can with "baggage"
But all's good
i
what I've done for those situations is use registration systems where the runtime can provide implementations that provide that information since System reading env variables breaks down in certain runtimes like JS web. In that kind of case, it doesn't necessarily make sense to use expect/actual if it likely can't have a reasonable actual on every target.
interfaces rather than expect/actual
a
Yeah, I just thought about that, but since I know this will only run in NodeJS (as well as JVM), I can use Node's process.env object
👍 1