org.scalajs.nodejs.drama.StateDrivenActor.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scalajs-npm-drama_sjs0.6_2.11 Show documentation
Show all versions of scalajs-npm-drama_sjs0.6_2.11 Show documentation
npm/drama binding for Scala.js
The newest version!
package org.scalajs.nodejs.drama
import org.scalajs.nodejs.drama.StateDrivenActor.ReplyScope
import scala.scalajs.js
import scala.scalajs.js.annotation.ScalaJSDefined
/**
* State-driven Actor
* @author [email protected]
*/
@ScalaJSDefined
class StateDrivenActor[T](initialState: T) extends js.Object {
private var state = initialState
def get: js.ThisFunction0[ReplyScope[T], Unit] = (scope: ReplyScope[T]) => scope.reply(state)
def set: js.Function = (newState: T) => state = newState
}
/**
* State-driven Actor Companion
* @author [email protected]
*/
object StateDrivenActor {
@js.native
trait ReplyScope[T] extends js.Object {
var reply: js.Function1[T, Unit] = js.native
}
}