Giter Club home page Giter Club logo

kanso's Introduction

Kanso

Kanso is a light-weight state-management library for web applications. Kanso's philosophy is to provide simple mechanics that can be used at your own discretion. You can use these patterns in many ways. Kanso molds to the skill of the user.

"By removing the non-essential and ornate, we can express a bare and honest simplicity."

Install

npm install --save @zenwolf/kanso

Overview

Encapsulated state

Kanso focuses on encapsulating state and logic, separating them from any UI layer. State is maintained in a single place and can be passed into another system for processing or rendering.

Kanso shapes the world: something else can render it into the visible realm.

No Defined UI layer

Kanso defines no specific UI, allowing you to use any UI technology you like. Your UI of choice will need to accept the entire state and use it as it sees fit. The UI will need to be able to create actions and dispatch them on the app object using the App#dispatch method.

Core concepts

  1. Unidirectional data flow that operates solely on actions/commands.
  2. Immutable state managed by state data stores.
  3. Interceptors to extend the core system:
    • action interceptors -- allow you to act upon an action or change the action/replace it before it is passed to stores and used to modify state.
    • state interceptors -- allow you to act upon a new state before it is set, or change it/replace it, before change listeners are called.
  4. Standard way to define state queries using QueryApi generator, which can be used statelessly(static methods) or statefully(bound to a specific state snapshot).

Responding to changes

Kanso gives you different ways to respond to changes:

  1. Intercept actions.
  2. Listen to state changes.

Interceptors

Interceptors are all composed into a single function call. The intial value is passed as the argument, and each function returns the same value type that is passed as the arugment to the next interceptor, until you end up with a single, resulting value which is then processed by the application.

Action Interceptors

An action interceptor is a function that allows you to receive an action before it is used to change state. The required function signature is:

action => action

You can return the same action, you could return a different action, or you could return a modified version of the same action. This is an extremely flexible system, hopefully allowing you to perform any number of things in response to an action.

State Interceptors

A state interceptor is a function that allows you to receive a new state before it is set. The required function signature is:

state => state

Much like an action interceptor, you can return the same state, return a different state, or return a modified version of the same state.

UI Strategies

Here are some strategies related to working with UI.

Build

Code generation

Kanso is written in ES6 and uses Babel to generate ES5 JS code. You run a build command to generate the resulting library from src into the lib folder.

npm run build

Code linting

Kanso uses eslint to lint code.

npm run lint

Run tests

Kanso uses mocha for unit tests.

npm test

Run verification (lint + test)

npm run verify

kanso's People

Contributors

zenwolf avatar

Watchers

 avatar  avatar

Forkers

marcacyr

kanso's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.