Liking cljdoc? Tell your friends :D

brain

An event looping abstraction to be used as the driving loop for a game engine, Elmish frontend, etc.

Important Links

builds.sr.ht status - ci.yml

Learning Links

Usage

Add the net.clojars.jamesaorson/brain Clojars project

Strict typing for the API surface can be enabled for your app by setting the env var BRAIN_STRICT_TYPING=1

Release

Clojars Project - Release

Latest

Clojars Project - Latest

Leiningen/Boot

[net.clojars.jamesaorson/brain "x.x.x"]

Clojure CLI/deps.edn

net.clojars.jamesaorson/brain {:mvn/version "x.x.x"}

Example

The minimal main program would be as follows

(ns examples.minimal.main
  (:require [net.clojars.jamesaorson.brain.core :refer (spark)]))

(defn msg-handler [{}] [false {}])

(defn -main
  [& _args]
  (spark {:msg-handler msg-handler}))

(-main)

Gradle

implementation("net.clojars.jamesaorson:brain:0.0.1")

Maven

<dependency>
  <groupId>net.clojars.jamesaorson</groupId>
  <artifactId>brain</artifactId>
  <version>0.0.1</version>
</dependency>

Examples

Refer to main.clj for an ever-evolving, documenting example project, meant to demonstrate every feature of the engine simultaneously.

Over time, this will lead to the most wild and insane application you can imagine.

Please help to make it so.

Additional examples will come to live in their namesake

Local Development

Local Development - Container

Local Development - Container - Repl

The easiest way to develop for this project is to run a repl in the provided container definition found in the Dockerfile.

The Dockerfile mounts this repo's source dir directly into the container, so any changes made in the codebase are reflected immediately in the repl container.

The container will automatically build when you run a container script. If you want to skip builds for any reason, you can disable automatic builds like so:

NO_CONTAINER_BUILD=1 ./scripts/container.repl.bash
# or, to skip container builds for the rest of the shell session
export NO_CONTAINER_BUILD=1

Run a clojure repl for this project in a container

$ ./scripts/container.repl.bash
...
Clojure 1.11.1
user=> ;; this is now a clojure repl

Local Development - Container - Lein

The default behavior of the container run script is to run lein check against your codebase. Passing an argument causes the arguments to be passed in place of check to lein

For example, ./scripts/container.run.bash compile would run lein compile

./scripts/container.run.bash

Local Development - Native Setup

You run a native setup without containerization, the first thing to do is to install babashka so all other setup scripts will work.

Local Development - Native Setup - Babashka

Install babashka

./scripts/install_babashka.bash

Local Development - Native Setup - Brew

On Linux, this is also referred to as linuxbrew

./scripts/install_brew.bb

Local Development - Native Setup - Clojure

Using brew:

./scripts/install_clojure.brew.bb

or, if on Linux, directly using the install script:

./scripts/install_clojure.linux.bb

Local Development - Native Setup - Leiningen

You can install leiningen using our script

./scripts/install_leiningen.manual.bb

Or you can install leiningen for your platform

Leiningen - For Debian/Ubuntu
sudo apt-get install -y leiningen
Leiningen -For MacOS or if using brew
brew install leiningen

Or using our script

Local Development - Native Setup - jq

For Debian/Ubuntu:

sudo apt-get install -y jq

For MacOS:

brew install jq

Local Development - Native

Local Development - Native - Lint

./scripts/lint.bb

Local Development - Native - Build

./scripts/build.bb

Local Development - Native - Run

./scripts/run.bb

Local Development - Native - Test

./scripts/test.bb

Local Development - Submitting a PR

Simply click this link, and follow the instructions here to create a patchset, sending the patchset email to the following for the brain mailing list: ~jamesaorson/brain@lists.sr.ht

Can you improve this documentation?Edit on sourcehut

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close