All Projects → kaiwu → weui-scalajs

kaiwu / weui-scalajs

Licence: other
write WeApp with scalajs

Programming Languages

scala
5932 projects
shell
77523 projects

Labels

Projects that are alternatives of or similar to weui-scalajs

Paradox
Markdown documentation
Stars: ✭ 229 (+1172.22%)
Mutual labels:  sbt
sbt-sonar
An sbt plugin which provides an easy way to integrate Scala projects with SonarQube.
Stars: ✭ 62 (+244.44%)
Mutual labels:  sbt
Converter
Typescript to Scala.js converter
Stars: ✭ 168 (+833.33%)
Mutual labels:  sbt
Sbt Dynver
An sbt plugin to dynamically set your version from git
Stars: ✭ 243 (+1250%)
Mutual labels:  sbt
sbt-ghpages
git, site and ghpages support for sbt projects.
Stars: ✭ 94 (+422.22%)
Mutual labels:  sbt
outwatch
The Functional and Reactive Web-Frontend Library for Scala.js
Stars: ✭ 444 (+2366.67%)
Mutual labels:  sbt
Reposilite
Lightweight repository management software dedicated for the Maven based artifacts (formerly NanoMaven) 📦
Stars: ✭ 222 (+1133.33%)
Mutual labels:  sbt
jgb
小程序渐进式编译框架
Stars: ✭ 21 (+16.67%)
Mutual labels:  weapp
sbt-babel
An SBT plugin to perform Babel compilation.
Stars: ✭ 12 (-33.33%)
Mutual labels:  sbt
sliding-puzzle
Sliding puzzle game implemented in Scala / Scala.js / JavaFX
Stars: ✭ 25 (+38.89%)
Mutual labels:  sbt
Ensime Sbt
Generates .ensime config files for SBT projects
Stars: ✭ 244 (+1255.56%)
Mutual labels:  sbt
etym
English Etymology application
Stars: ✭ 86 (+377.78%)
Mutual labels:  weapp
sbt-sass
A fork of the sbt-sass repository which seems to be abandoned.
Stars: ✭ 32 (+77.78%)
Mutual labels:  sbt
Sbt Fresh
sbt-plugin to create an opinionated fresh sbt project
Stars: ✭ 229 (+1172.22%)
Mutual labels:  sbt
akka-http-docker-sample
example of running an Sbt application in Docker based on openjdk:jre-alpine
Stars: ✭ 20 (+11.11%)
Mutual labels:  sbt
Sbt Tpolecat
scalac options for the enlightened
Stars: ✭ 227 (+1161.11%)
Mutual labels:  sbt
sbt-avro
Plugin SBT to Generate Scala classes from Apache Avro schemas hosted on a remote Confluent Schema Registry.
Stars: ✭ 15 (-16.67%)
Mutual labels:  sbt
scalarr
A command-line client for Sonarr, written in Scala
Stars: ✭ 33 (+83.33%)
Mutual labels:  sbt
sbt-graphql
SBT plugin to generate and validate graphql schemas written with Sangria
Stars: ✭ 94 (+422.22%)
Mutual labels:  sbt
wechat-webapp-douban-location
微信小程序开发之豆瓣同城
Stars: ✭ 73 (+305.56%)
Mutual labels:  weapp

Scala.js

WeApp meets Scala.js

By implementing WeUI demo, this project is a POC that WeChat App can be implemented with Scala.js and SBT, specifically, it uses the Scala.js plugin to compile Scala sources and sbt-less to compile style sources.

A few motivations behind the project :

  1. Enjoy the Scala ecosystem !
  2. Avoid this and that of JavaScript and all of its hells and pitfalls, Scala causes much less hassles.
  3. WePY, the Tencent backed framework, only created extra boilerplates.

Following is a typical array of asynchronous calls, written in Scala way

def onLoad(): Unit = {
  val info = for {
    msg  <- Wechat.login{}
    info <- Wechat.getUserInfo(false,"en"){}
  } yield info

  Wechat.setData("userInfo", info)
}

How to use

sbt > assets
sbt > fullOptJS

Then use WeApp Development Tool to open the target directory. Under WeApp circumstances it makes no sense to do fastOptJS, since fullOptJS generates highly optimized JavaScript already, these options will need to be turned OFF from the project's settings:

  • convert Es6 to Es5
  • autocomplete on upload
  • compress on upload

Each page is built as a separate sbt project, so one can always use the project specific sbt tasks, for example

sbt > progress/fullOptJS
sbt > images/assets

Caveats

Component

Scala.js supports component based development, as illustrated by page example/component/component, if a component is written in Javascript it can be used directly in pages. If a component is written in Scala.js and it defines custom event, be careful to resolve the needed handlers from onReady of Pages instead of methods of Components, because Scala.js cannot (for the good) declare a magic this, which is a major sources of mystery of Javascript

Facade

For demo purpose, it does not complete the entire WeApp facade, nevertheless, this work is straightforward and could be supplemented as WeApp itself is evolving.

SBT

SBT is hard

Less

To use Less and the sbt plugin, all the secondary component files are prefixed with underscore, such as _weui.wxss

Others

Scala.js compiler keeps bundling those Javascript sources in the webjar, which will be picked up and loaded by WeApp. Since WeApp requires the size be less than 2M, we can simply remove the unneeded classes folders. You can use the cleanup.sh script directly.

project $ ./cleanup.sh

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].