Posts

Showing posts from April, 2019

copying scala.js linker artifacts after linking

copying scala.js linker artifacts after linking There have been a few requests for a plugin to copy the scala.js linker artifacts to another location after the linker has run. While you could set the output path for the artifact to a different location, you may want to have the artifacts generated into the standard location then copy it to somewhere else to provide better compatibility with existing tooling. Ad-hoc Approach Here’s one way to add a copy process to a specific sub-project: def copyTask ( odir : String ) = { lazy val copyJSOutput = taskKey [ Unit ] ( "copy scala.js linker outputs to another location" ) Seq ( copyJSOutput : = { println ( s "Copying artifact ${scalaJSLinkedFile.in(Compile).value.path} to [${odir}]" ) val src = file ( scalaJSLinkedFile . in ( Compile ) . value . path ) IO . copy ( Seq ( ( src , file ( odir ) / src . name ) , ( file ( src . getCanonicalP...

user experience, scala.js, cats-effect, IO

user experience, scala.js, cats-effect, IO This is not a complicated snippet but I wanted to ensure I remembered it. When creating a UI, say react for browsers, you will run into the “fetch” data problem. When you fetch data, you typically have a component that performs the fetch and acts as a cache for the result. The fetch component renders a child and passes along the data that was fetched (or the fetch state, etc.). Even with the upcoming react suspense mechanism that will make this a smoother user experience, you may have a flash of a “loading” indicator that shows for a moment before the content is fetched from the server. If the flash is too fast, it is visually disruptive. A shimmer mechanism for the UI my also not be the answer. Similarly, if the fetch request takes too long, you will want it to time-out and show an error message that the data could not be fetched or whatever is appropriate for feedback in your application. Generally, I use cats-effect...