All Projects → jongacnik → Monoapp

jongacnik / Monoapp

choo architecture without a renderer

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Monoapp

Riot
Simple and elegant component-based UI library
Stars: ✭ 14,596 (+27969.23%)
Mutual labels:  framework, minimal
Displayjs
A simple JavaScript framework for building ambitious UIs 😊
Stars: ✭ 590 (+1034.62%)
Mutual labels:  framework, dom
picoCSS
picoCSS - really small JavaScript Framework
Stars: ✭ 62 (+19.23%)
Mutual labels:  dom, minimal
Sifrr
⚡️ Set of tiny, independent libraries for creating modern and fast webapps with javascript/typescript
Stars: ✭ 174 (+234.62%)
Mutual labels:  framework, minimal
Framework
MomentPHP | The PHP mini-framework based on Slim and Laravel Components
Stars: ✭ 6 (-88.46%)
Mutual labels:  framework, minimal
Youi
Next generation user interface and application development in Scala and Scala.js for web, mobile, and desktop.
Stars: ✭ 186 (+257.69%)
Mutual labels:  framework, dom
Bunny
BunnyJS - Lightweight native (vanilla) JavaScript (JS) and ECMAScript 6 (ES6) browser library, package of small stand-alone components without dependencies: FormData, upload, image preview, HTML5 validation, Autocomplete, Dropdown, Calendar, Datepicker, Ajax, Datatable, Pagination, URL, Template engine, Element positioning, smooth scrolling, routing, inversion of control and more. Simple syntax and architecture. Next generation jQuery and front-end framework. Documentation and examples available.
Stars: ✭ 473 (+809.62%)
Mutual labels:  framework, dom
Holmes
Fast and easy searching inside a page
Stars: ✭ 1,679 (+3128.85%)
Mutual labels:  minimal, dom
Choo
🚂🚋 - sturdy 4kb frontend framework
Stars: ✭ 6,637 (+12663.46%)
Mutual labels:  minimal, dom
Slim.js
Fast & Robust Front-End Micro-framework based on modern standards
Stars: ✭ 789 (+1417.31%)
Mutual labels:  framework, dom
Amplesdk
Ample SDK - JavaScript UI Framework
Stars: ✭ 169 (+225%)
Mutual labels:  framework, dom
Fbbot
Minimal framework/SDK for facebook messenger bots. BYOS (Bring Your Own Server)
Stars: ✭ 46 (-11.54%)
Mutual labels:  framework, minimal
Mag.js
MagJS - Modular Application Glue
Stars: ✭ 157 (+201.92%)
Mutual labels:  framework, dom
Mu
The μ css framework — a 1 ko css file.
Stars: ✭ 202 (+288.46%)
Mutual labels:  framework, minimal
Canjs
Build CRUD apps in fewer lines of code.
Stars: ✭ 1,881 (+3517.31%)
Mutual labels:  framework, dom
crab
JavaScript library for building user interfaces with Custom Elements, Shadow DOM and React like API
Stars: ✭ 22 (-57.69%)
Mutual labels:  dom, minimal
Chota
A micro (3kb) CSS framework
Stars: ✭ 733 (+1309.62%)
Mutual labels:  framework, minimal
Crab
JavaScript library for building user interfaces with Custom Elements, Shadow DOM and React like API
Stars: ✭ 22 (-57.69%)
Mutual labels:  minimal, dom
Lemon
🍋 Minimal and responsive CSS framework for fast building websites.
Stars: ✭ 51 (-1.92%)
Mutual labels:  framework, minimal
Angel
A polished, production-ready backend framework in Dart for the VM, AOT, and Flutter.
Stars: ✭ 1,055 (+1928.85%)
Mutual labels:  framework

monoapp

API stability NPM version Standard Size

choo architecture without a renderer. Bring-your-own view layer.

Overview

monoapp is an opinionated fork of choo, a small frontend framework with a simple, functional architecture. Read-up on the choo documentation for details on routing, events, and the architecture in general.

In monoapp, we have removed the modules used to render the dom (nanohtml and nanomorph), and made these pluggable instead. This allows us to build apps using choo architecture, but render views and components however we would like. See the examples directory for using with react, lit-html, vue, nanomorph, etc.

Example

Clone of the choo example, but we bring nanohtml and nanomorph ourselves.

var html = require('nanohtml')
var morph = require('nanomorph')
var monoapp = require('monoapp')
var devtools = require('choo-devtools')

var app = monoapp({
  mount: morph,
  render: morph
})

app.use(devtools())
app.use(countStore)
app.route('/', mainView)
app.mount('body')

function mainView (state, emit) {
  return html`
    <body>
      <h1>count is ${state.count}</h1>
      <button onclick=${onclick}>Increment</button>
    </body>
  `

  function onclick () {
    emit('increment', 1)
  }
}

function countStore (state, emitter) {
  state.count = 0
  emitter.on('increment', function (count) {
    state.count += count
    emitter.emit('render')
  })
}

You could also choose to define mount and render using a simple plugin, rather than passing as options:

app.use(withNanomorph)

function withNanomorph (state, emitter, app) {
  app._mount = morph
  app._render = morph
}

API

The only items documented here are the methods to implement. These can be defined as options when creating a monoapp instance, or can be set with a plugin. Refer to the choo documentation for anything related to app architecture (routing, state, and events).

app._mount(tree, newTree, root)*

Mount tree onto the root:

app._mount = (tree, newTree, root) => nanomorph(tree, newTree)

app._render(tree, newTree, root)*

Render new tree:

app._render = (tree, newTree, root) => nanomorph(tree, newTree)

app._toString(tree)

Convert tree to string. This method is useful for ssr:

app._toString = (tree) => tree.toString()

*Required

Plugins

Some plugins to use with monoapp which take care of common configs:

More Examples

Why does this exist?

choo is really calm and we like to build apps using it. That said, sometimes nanohtml and nanomorph aren't the best tools for the job. We wanted to be able to build apps using choo architecture but swap out the view layer and make use of other component ecosystems when a project calls for it.

Notes

monoapp is currently feature-matched to choo 6.13.1

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].