Skip to content

Commit

Permalink
Renamed TyrianAppF to TyrianApp
Browse files Browse the repository at this point in the history
  • Loading branch information
davesmith00000 committed Apr 11, 2024
1 parent d148713 commit 2a4c0f8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions tyrian-io/src/main/scala/tyrian/TyrianIOApp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import cats.effect.unsafe.implicits.global
/** The TyrianApp trait can be extended to conveniently prompt you for all the methods needed for a Tyrian app, as well
* as providing a number of standard app launching methods.
*/
trait TyrianIOApp[Msg, Model] extends TyrianAppF[IO, Msg, Model]:
trait TyrianIOApp[Msg, Model] extends TyrianApp[IO, Msg, Model]:

val run: IO[Nothing] => Unit = _.unsafeRunAndForget()

object TyrianIOApp:
def onLoad(appDirectory: (String, TyrianAppF[IO, ?, ?])*): Unit =
TyrianAppF.onLoad(appDirectory*)
def onLoad(appDirectory: (String, TyrianApp[IO, ?, ?])*): Unit =
TyrianApp.onLoad(appDirectory*)

def launch(appDirectory: Map[String, TyrianAppF[IO, ?, ?]]): Unit =
TyrianAppF.launch(appDirectory)
def launch(appDirectory: Map[String, TyrianApp[IO, ?, ?]]): Unit =
TyrianApp.launch(appDirectory)
10 changes: 5 additions & 5 deletions tyrian-zio/src/main/scala/tyrian/TyrianZIOApp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import scala.annotation.nowarn
/** The TyrianApp trait can be extended to conveniently prompt you for all the methods needed for a Tyrian app, as well
* as providing a number of standard app launching methods.
*/
trait TyrianZIOApp[Msg, Model](using Async[Task]) extends TyrianAppF[Task, Msg, Model]:
trait TyrianZIOApp[Msg, Model](using Async[Task]) extends TyrianApp[Task, Msg, Model]:

private val runtime = Runtime.default

Expand All @@ -21,8 +21,8 @@ trait TyrianZIOApp[Msg, Model](using Async[Task]) extends TyrianAppF[Task, Msg,
}

object TyrianZIOApp:
def onLoad(appDirectory: (String, TyrianAppF[Task, ?, ?])*)(using Async[Task]): Unit =
TyrianAppF.onLoad(appDirectory*)
def onLoad(appDirectory: (String, TyrianApp[Task, ?, ?])*)(using Async[Task]): Unit =
TyrianApp.onLoad(appDirectory*)

def launch(appDirectory: Map[String, TyrianAppF[Task, ?, ?]])(using Async[Task]): Unit =
TyrianAppF.launch(appDirectory)
def launch(appDirectory: Map[String, TyrianApp[Task, ?, ?]])(using Async[Task]): Unit =
TyrianApp.launch(appDirectory)
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import scala.scalajs.js.annotation.*
/** The TyrianApp trait can be extended to conveniently prompt you for all the methods needed for a Tyrian app, as well
* as providing a number of standard app launching methods.
*/
trait TyrianAppF[F[_]: Async, Msg, Model]:
trait TyrianApp[F[_]: Async, Msg, Model]:

/** Specifies the number of queued tasks that can be consumed at any one time. Default is 1024 which is assumed to be
* more than sufficient, however the value can be tweaked in your app by overriding this value.
Expand Down Expand Up @@ -111,7 +111,7 @@ trait TyrianAppF[F[_]: Async, Msg, Model]:

def ready(node: Element, flags: Map[String, String]): Unit =
run(
TyrianAppF.start[F, Model, Msg](
TyrianApp.start[F, Model, Msg](
node,
router,
_init(flags),
Expand All @@ -130,11 +130,11 @@ trait TyrianAppF[F[_]: Async, Msg, Model]:
case None =>
throw new Exception(s"Missing Element! Could not find an element with id '$containerId' on the page.")

object TyrianAppF:
object TyrianApp:
/** Launch app instances after DOMContentLoaded.
*/
@nowarn("msg=discarded")
def onLoad[F[_]: Async](appDirectory: Map[String, TyrianAppF[F, ?, ?]]): Unit =
def onLoad[F[_]: Async](appDirectory: Map[String, TyrianApp[F, ?, ?]]): Unit =
val documentReady = new Promise((resolve, _reject) => {
document.addEventListener("DOMContentLoaded", _ => resolve(()))
if (document.readyState != DocumentReadyState.loading) {
Expand All @@ -144,12 +144,12 @@ object TyrianAppF:
})
documentReady.`then`(_ => launch[F](appDirectory))

def onLoad[F[_]: Async](appDirectory: (String, TyrianAppF[F, ?, ?])*): Unit =
def onLoad[F[_]: Async](appDirectory: (String, TyrianApp[F, ?, ?])*): Unit =
onLoad(appDirectory.toMap)

/** Find data-tyrian-app HTMLElements and launch corresponding TyrianAppF instances
/** Find data-tyrian-app HTMLElements and launch corresponding TyrianApp instances
*/
def launch[F[_]: Async](appDirectory: Map[String, TyrianAppF[F, ?, ?]]): Unit =
def launch[F[_]: Async](appDirectory: Map[String, TyrianApp[F, ?, ?]]): Unit =
document.querySelectorAll("[data-tyrian-app]").foreach { element =>
val tyrianAppElement = element.asInstanceOf[HTMLElement]
val tyrianAppName = tyrianAppElement.dataset.get("tyrianApp")
Expand Down

0 comments on commit 2a4c0f8

Please sign in to comment.