All Projects → przemyslawjanpietrzak → rembrandt

przemyslawjanpietrzak / rembrandt

Licence: MIT license
Simple UI framework written in Reasonml.

Programming Languages

reason
219 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to rembrandt

lwt-node-starter
A simple starter for lwt-node
Stars: ✭ 13 (-83.95%)
Mutual labels:  reasonml
reason-cookie
A simple way to use cookies in Reason (OCaml) on the frontend. 🍪
Stars: ✭ 18 (-77.78%)
Mutual labels:  reasonml
bs-axios
Bucklescript bindings for axios
Stars: ✭ 74 (-8.64%)
Mutual labels:  reasonml
streaming
Fast, safe and composable streaming abstractions.
Stars: ✭ 104 (+28.4%)
Mutual labels:  reasonml
serverless-reasonml
serverless framework plugin for writing functions with Reason
Stars: ✭ 13 (-83.95%)
Mutual labels:  reasonml
nibbledb
a byte-sized time series database
Stars: ✭ 23 (-71.6%)
Mutual labels:  reasonml
reasonml-idea-plugin
ReasonML Language Plugin for IDEA
Stars: ✭ 320 (+295.06%)
Mutual labels:  reasonml
vscode-graphiql-explorer
Use GraphiQL + GraphiQL Explorer to build your GraphQL operations, right from inside of VSCode.
Stars: ✭ 35 (-56.79%)
Mutual labels:  reasonml
bs-react-fela
BuckleScript bindings for react-fela
Stars: ✭ 21 (-74.07%)
Mutual labels:  reasonml
bs-reason-apollo
ReactApollo bindings for BS
Stars: ✭ 23 (-71.6%)
Mutual labels:  reasonml
reason-tree-sitter
ReasonML bindings for tree-sitter
Stars: ✭ 22 (-72.84%)
Mutual labels:  reasonml
revery-packager
Helper utility to package Revery applications into installable app bundles
Stars: ✭ 38 (-53.09%)
Mutual labels:  reasonml
re-typescript
An opinionated attempt at finally solving typescript interop for ReasonML / OCaml.
Stars: ✭ 68 (-16.05%)
Mutual labels:  reasonml
bs-remotedata
RemoteData and WebData to use with bs-fetch for BuckleScript
Stars: ✭ 18 (-77.78%)
Mutual labels:  reasonml
jsoo-react
js_of_ocaml bindings for ReactJS. Based on ReasonReact.
Stars: ✭ 126 (+55.56%)
Mutual labels:  reasonml
reason-react-native-example
ReasonML React Native (Expo) example
Stars: ✭ 14 (-82.72%)
Mutual labels:  reasonml
re-use
⚛️ 🎣 A collection of hooks for ReasonReact
Stars: ✭ 27 (-66.67%)
Mutual labels:  reasonml
bs-decode
Type-safe JSON decoding for ReasonML and OCaml
Stars: ✭ 105 (+29.63%)
Mutual labels:  reasonml
reason-hooks-testing-library
ReasonML bindings for react-hooks-testing-library
Stars: ✭ 24 (-70.37%)
Mutual labels:  reasonml
tea-chess
A chess-themed tutorial on writing an SPA in Bucklescript-TEA
Stars: ✭ 28 (-65.43%)
Mutual labels:  reasonml

Rembrandt

CircleCI License: MIT npm version

alt text

Simple functional UI framework written in Reasonml.

Getting started

yarn add bs-rembrandt

Create seed project:

yarn bs-rembrandt init

Build production files:

yarn bs-rembrandt build

Run dev server:

yarn bs-rembrandt start:bs

And in another terminal:

yarn bs-rembrandt start:js

Run unit tests:

yarn bs-rembrandt test

Display all available commands in CLI:

yarn bs-rembrandt help

Example app

open Rembrandt.Elements;

type model = int;
type action =
  | Add
  | Sub
  | Twice;

let update =
    (model: model, action: action): (model, Command.command('action)) =>
  switch (action) {
  | Add => (model + 1, Command.null)
  | Sub => (model - 1, Command.null)
  | Twice => (model + 1, Command.action(Add))
};

Rembrandt.run(
  ~model=42,
  ~update,
  ~view=
    (model, dispatch) =>
      <div>
        <div id="count"> {string_of_int(model) |> text} </div>
        <button id="plus" onClick={_ => Add |> dispatch}>
          {"+" |> text}
        </button>
        <button id="minus" onClick={_ => Sub |> dispatch}>
          {"-" |> text}
        </button>
        <button id="double" onClick={_ => Twice |> dispatch}>
          {"twice +" |> text}
        </button>
      </div>,
  (),
);

API

model

Initial store value.

update

Function for modify model. It takes current model and dispatched action. It returns 2 element tuple with new model and command.

command

Way to run side effects in asynchronously. Command.null wouldn't run anything, Command.action will dispatch action asynchronously, Command.run will run passed function with dispatch as argument.

view

On every state change result on function will be render on rootNode. Argument dispatch should be call with proper action on DOM event callback.

rootId (optional)

String for find rootNode via document.getElementById. Default is app.

initAction (optional)

Action to dispatch after first render. Default is Command.null.

middlewares (optional):

List of functions to apply on each state update. Each takes oldModel, newModel and action as arguments. See Rembrandt.MiddleWares.logger in examples/Form.re. Default is [].

subscription (optional):

Function that takes current model and dispatch as argument. Allows to dispatch action based on asynchronous source (e.g. websocket) See in examples/Subscription.re. Default is (model, dispatch)=> ().

Shadow Dom

To wrap elements in shadow dom you can use the <shadowRoot> element imported from Rembrandt.Elements as other components. It will render <div> element with shadowRoot. To attach a close shadow DOM use <shadowRoot mode=ShadowDomCloseMode>, however it's not recommended to use it for display model-related data. See examples/ShadowDom.re.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].