Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Merge pull request #130 from fomkin/hotfix-129
Browse files Browse the repository at this point in the history
Fix #129: Direcly apply immitiate transition before deferred
  • Loading branch information
fomkin authored Jul 2, 2017
2 parents 2a4ee6b + a630144 commit 83c3cf4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ Our project supports static page rendering, so that search engines can index pag
Add `korolev-server` to your `build.sbt`

```scala
libraryDependencies += "com.github.fomkin" %% "korolev-server-blaze" % "0.4.0"
libraryDependencies += "com.github.fomkin" %% "korolev-server-blaze" % "0.4.1"
```

Look at [examples](https://github.com/fomkin/korolev/tree/v0.4.0/examples). It updates very frequently, so we don't paste the code here, sorry guys.
Look at [examples](https://github.com/fomkin/korolev/tree/v0.4.1/examples). It updates very frequently, so we don't paste the code here, sorry guys.

## Architecture

Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ val publishSettings = Seq(
val commonSettings = publishSettings ++ Seq(
scalaVersion := "2.11.11", // Need by IntelliJ
organization := "com.github.fomkin",
version := "0.4.0",
version := "0.4.1",
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.0.1" % "test"
),
Expand Down
14 changes: 9 additions & 5 deletions korolev/src/main/scala/korolev/Korolev.scala
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,16 @@ object Korolev {
case event: ApplicationContext.EventWithAccess[F, S, M] => event.effect(browserAccess)
case event: ApplicationContext.SimpleEvent[F, S, M] => event.effect()
}
eventResultOpt.fold(true) { er =>
List(er.it.map(async.pure(_)), er.dt).flatten.foreach { transitionF =>
async.run(transitionF) {
case Success(transition) => stateManager(transition).runIgnoreResult()
case Failure(e) => logger.error("Exception during applying transition", e)
eventResultOpt.fold(true) { er: EventResult[F, S] =>
// Apply immediate transition
er.it.fold(async.unit)(it => stateManager(it)) flatMap { _ =>
// Apply deferred transition
er.dt.fold(async.unit) { transitionF =>
transitionF.map(stateManager.apply)
}
} run {
case Success(_) => // ok transitions was applied
case Failure(e) => logger.error("Exception during applying transition", e)
}
!er.sp
}
Expand Down
2 changes: 1 addition & 1 deletion korolev/src/main/scala/korolev/StateManager.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ object StateManager {
subscribers.foreach(f => f(newState))
promise.complete(Success(()))
case None =>
promise.complete(Failure(new Exception("Transition don't fit this state")))
promise.complete(Failure(new Exception("Transition doesn't fit this state")))
}
} catch {
case e: Throwable =>
Expand Down

0 comments on commit 83c3cf4

Please sign in to comment.