Brookjs Docs
HomeWell-StructuredTestableInfluencesCommunityChangelog
Getting Started
Walkthrough
Advanced Concepts
Philosophy
API

brookjs

brookjs combines React/Redux with reactive programming tools to enable well-structured, testable applications.

Well-Structured

brookjs enables you to output events in your components through streams. Components get callbacks that map events to values in the stream, and the streams themselves can map those values to the relevant Redux events. Those are then piped into Redux, which manages the state of the entire application. The loop is closed when the state is mapped into the view. Thus, components become solely an expression of I/O, maintaining no internal state by default.

Applications can be embedded within one another, enabling the application to be fractalized. Events are emitted out of each nested fractal into the parent layer, which can manage its own state with a reducer. In this way, an application can be internally complete while nested inside larger apps.

Side effects can read from the stream of actions as well as a stream state to make API calls, read or write to a web socket, or manage a worker. The reducer can send commands to these side effects, allowing the reducer to manage both the current state of the application as well as what happens next. With side effects pushed into a corner, all application logic is defined in the Redux store.

Testable

With your components acting as I/O, testing them requires passing in state and ensuring the correct DOM is emitted, and triggering DOM events against them and ensuring the correct events are emitted. All side effects in your application can be tested like this, ensuring the communication channels out of the application function as expected.

Your application logic is expressed in your reducers, which are all pure functions. This makes them easy to test, checking that a state & action combination produces the expected new state & next action.

Integration testing can be handled by replacing I/O with a matching mock I/O, controlling what events are emitted in response to what commands. You can drive your application at every level, from small unit tests handling detailed logic, integration tests ensuring a particular piece of the application runs as expected, all the way up to full end-to-end tests in the browser.

Influences

  • React/Redux
  • Cycle.js
  • Karet
  • redux-observable
  • elm
  • Ports & Adapters Architecture
  • Actor Model
  • Event sourcing
  • CQRS

Community