zliq
v2.0.1
Published
slim and quick framework in low loc
Downloads
189
Readme
ZLIQ
ZLIQ is the intent to create an easy to understand, easy to use web framework. It is based on reactive-streams and reactive-dom-rendering. ZLIQ has few lines of code (~580 November 2017).
Website
Why yet another web framework?
Modern web frameworks got really big (React + Redux 139Kb and Angular 2 + Rx 766Kb, [src]). As a developer I came into the (un)pleasent situation to teach people how these work. But I couldn't really say, as I haven't actually understood each line of code in these beasts. But not only that, they also have a lot of structures I as a developer have to learn to get where I want to go. It feels like learning programming again just to be able to render some data.
ZLIQ tries to be sth simple. Sth that reads in an evening. But that is still so powerful you can just go and display complex UIs with it. Sth that feels more JS less Java.
Still ZLIQ doesn't try to be the next React or Angular! ZLIQ has a decent render speed even up to several hundred simultaneous updates but it's not as fast as Preact. And it on purpose does not solve every problem you will ever have. ZLIQ is a tool to help you create the solution that fits your need.
Quickstart
To play around with ZLIQ fork this repo and start the demo page at localhost:8080
:
$ npm start
To use ZLIQ in your project, first install it as an dependency:
$ npm install --save zliq
Then create your app component and add it to the DOM:
import {h, render} from 'zliq';
let app = <div>
<span>Hello World</span>
</div>;
render(app, document.querySelector('#app');
ZLIQ includes streams similar to flyd to make state easy to handle:
import {h, render} from 'zliq';
// define a stream of state
let state$ = stream({ clicks: 0 });
// Redux like action
let increment = (state$) => () => {
state$.patch({ clicks: state$.$('clicks')() + 1 })
};
let app = <div>
// display from state
<p>Clicks: {state$.$('clicks')}</p>
// interact with state
<button onclick={increment(state$)}>Click + 1</button>
</div>;
render(app, document.querySelector('#app');
Make sure your stack converts JSX to Hyperscript syntax. In the ZLIQ project this is achieved with Babel and the transform-h-jsx plugin used in webpack. Alternative you can use Babel in the browser, like I did in the ZLIQ playground.
If you don't want to use JSX you can still write plain Hyperscript:
let app = h('div', null, [
h('span', null, ["Hello World"])
]);
Dive in
Checkout the Git Page as a live example of a ZLIQ app (the code lives under ./demo
). There you will also find a tutorial and more detailed descriptions on ZLIQs parts.
Plugins
There are some plugins available to enhance the zliq experience:
- ZLIQ-Router: A simple stream based router
- ZLIQ-Stacktrace: A wrapper around Sourcemapped-Stacktrace to prune the stacktrace to only the necessary
Contributors
Thanks goes to these wonderful people (emoji key):
| Fabian💻 🎨 📖 ⚠️ | Ferit Topcu📖 | | :---: | :---: |
This project follows the all-contributors specification. Contributions of any kind welcome!
Logo based on: http://www.iconsfind.com/2015/11/25/candy-dessert-food-sweet-baby-icon/