Giter Club home page Giter Club logo

outwatch's Introduction

Outwatch

The Functional and Reactive Web-Frontend Library for ScalaJS

Typelevel incubator Scala.js Gitter chat

import outwatch._
import outwatch.dsl._
import colibri._
import cats.effect.{IO, SyncIO}

object Main {
  def main(args: Array[String]): Unit = {
    
    val myComponent = SyncIO {
      val counter = Subject.behavior(0)
      div(
        button("+", onClick(counter.map(_ + 1)) --> counter),
        counter,
      )
    }

    OutWatch.renderReplace[IO]("#app", myComponent).unsafeRunSync()
  }
}

In Outwatch, you can describe your whole web application without doing any side effect - you only run your application when rendering it.

  • Write UI-components using pure functions
  • Manage state in a referentially transparent way using cats-effect
  • Built-in lightweight Observable and Subject types from colibri
  • Seamlessly works with existing reactive programming libraries: Monix, scala.rx
  • Low-boilerplate, many convenient helper functions
  • Built on top of snabbdom, a virtual dom library

You will find interactive examples and explanations in our documentation.

Quickstart

Template

The quickest way to play with outwatch is to use our template.

Make sure that java, sbt, nodejs and yarn are installed.

sbt new outwatch/seed.g8

In your newly created project directory, run:

sbt dev

and point your browser to http://localhost:8080.

Manual setup

Add the scalajs and scalajs-bundler plugins to your project/plugins.sbt:

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.x.x")
addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "x.x.x")

Add the outwatch dependencies to your build.sbt:

enablePlugins(ScalaJSPlugin)
enablePlugins(ScalaJSBundlerPlugin)

resolvers += "jitpack" at "https://jitpack.io"
val outwatchVersion = "<latest git commit>"
libraryDependencies ++= Seq(
  "com.github.outwatch.outwatch" %%% "outwatch"      % outwatchVersion,
  // optional dependencies:
  "com.github.cornerman.colibri" %%% "colibri-monix" % outwatchVersion, // Monix
  "com.github.cornerman.colibri" %%% "colibri-rx"    % outwatchVersion, // Scala.rx
  "com.github.outwatch.outwatch" %%% "outwatch-util" % outwatchVersion, // Store, Websocket, Http
)

Bugs and Feedback

For bugs, questions and discussions please use GitHub Issues.

Community

We adopted the Scala Code of Conduct. People are expected to follow it when discussing Outwatch on the Github page, Gitter channel, or other venues.

LICENSE

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

outwatch's People

Contributors

cornerman avatar scala-steward avatar fdietze avatar mariusmuja avatar lukajcb avatar zakpatterson avatar perwiklander avatar busti avatar kadekm avatar thsoft avatar asakaev avatar ahjohannessen avatar guizmaii avatar

Watchers

James Cloos avatar  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.