Giter Club home page Giter Club logo

akka.js's Introduction

Akka.Js

Scala.js

Join the chat at https://gitter.im/unicredit/akka.js

This repository is an ongoing effort to port Akka to the JavaScript runtime, thanks to Scala.js

LIVE DEMO

Use it

To have a blazing fast kick off you can check out our examples.

Otherwise, if you want to start from scratch:

First of all you need to setup a new Scala.js project. Then add to your JS project configuration:

libraryDependencies += "eu.unicredit" %%% "akkajsactor" % "0.2.4.11"

If you want to use Akka Stream:

libraryDependencies += "eu.unicredit" %%% "akkajsactorstream" % "0.2.4.11"

Please note that Akka.js 0.2.4.11 is shipped from the stable Akka 2.4.11. At this point you can use most of the Akka core Api as described in the official docs.

Check out the @andreaTP session at Scala Days 2016: slides video

Caveats

There are small caveats to keep in mind to ensure that your code will run smoothly on both Jvm and Js.

Startup Time On Js VM we cannot block, so to ensure your code will run AFTER the ActorSystem scheduler is started you need to run your code within a block like this:

import system.dispatcher
import scala.concurrent.duration._
system.scheduler.scheduleOnce(0 millis){
  ... your code here ...
}

Reflective Actor Instatiation On JVM you are used instatiating your actors like:

system.actorOf(Props(classOf[MyActor]))

Unfortunately this wont work out of the box on Scala.Js. The easiest way to fix it is to use the non-reflective constructor:

system.actorOf(Props(new MyActor()))

If you really want to use the reflective one you need two steps.

  • Verify that your class is exported to JavaScript properly marking it with JSExport and ensuring there are no compile-time errors (you can remove the annotation after the check)
  • Add it to the list of dynamically loadable actors before starting the ActorSystem:
akka.actor.JSDynamicAccess.injectClass("StringClassNameOfT" -> classOf[T])

Design documentation

The BSc thesis detailing most of the work and the approach taken can be found here

The original codebase derives from Sébastien Doeraene's scala-js-actors, you can find his original report here.

Build it

To work with the very last version you can compile and publish local:

git clone https://github.com/unicredit/akka.js
cd akka.js
sbt akkaJsActorJS/publishLocal

To have also the bleeding edge integration of akka-stream:

sbt akkaJsActorStreamJS/publishLocal

Akka version

Akka.Js can now compile against different versions of Akka, we check the codebase against MASTER, but for specific needs you can try to compile against a different Akka version by changing the akkaVersion while building.

License

Akka.js is distributed under the Scala License.

akka.js's People

Contributors

andreatp avatar yawnt avatar solomono avatar fralken avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.