CrossClj

0.3.6 docs

SourceDocs



RECENT

    keechma

    Clojars

    Apr 20, 2018


    OWNER
    keechma

    Readme

    Index of all namespaces


    « Project + dependencies

    Frontend micro framework for ClojureScript and Reagent

    keechma.controller — cljsDocsSource
    Controllers in Keechma are the place where you put the code
    that has side-effects. They are managed by the [[keechma.controller-manager]]
    which will start them or stop them based on the current route.
    
    Each controller implements the params function. params function returns
    a subset of the route params that are the controller is interested in.
    
    For instance let's say that you have a UserController which should be
    running only when the user is on the route /users:
    
    `clojure
    ;; let's say that your routes are defined like this:
    
    (def routes [":page"]) ;; Routes are managed by the app-state library.
    
    ;; When user goes to the url /users the params function would receive
    ;; something that looks like this:
    
    {:data {:page "users"}}
    
    ;; params function returns true only when user is on the :page "users"
    (defrecord UserController [])
    
    (defmethod controller/params UserController [_ route-params]
      (when (= "users" (get-in route-params [:data :page]))
       true))
    `
    
    When params function returns a non nil value the controller will be started:
    
    1. Controller's start function will be synchronously called with the current
    application state. This function returns a new version of the state if needed.
    (if the start function is not doing any changes to the app-state it must return
    the received version)
    2. Controller's handler function will be called - this function will receive
    application state atom, channel through which the controller receives the commands
    (in-chan) and the channel through which the controller can send commends to
    other controllers (out-chan).
    
    When params function returns a nil value that instance of the controller will
    be stopped:
    
    1. Controller's stop function will be synchronously called with the current
    application state. This function returns a new version of the state if needed - 
    use this function to clean up any data loaded by the controller (if the stop 
    function is not doing any changes to the app-state it must return the received
    version).
    2. Controller's in-chan (through which it can receive commands) will be closed.
    
    Controller's start and stop functions can asynchronuously send commends to the
    controller. Calling `(execute controller-instance :command)` will put that command
    on the controller's in-chan. Controller can react to these commands from the 
    handler function.
    The README below is fetched from the published project artifact. Some relative links may be broken.

    Keechma

    Clojars Project

    Keechma is a micro framework for Reagent written in ClojureScript. It gives you a set of utilites that allow you to build applications that have the following properties:

    • Deterministic and predictable behavior
      • Based on the route, you can determine what the application’s state will be
      • UI never “requests” data it’s always provided to it
    • Unidirectional data flow
      1. Route params are derived from the URL
      2. Application state is derived from the route params
      3. UI is derived from the application state
    • Loose coupling between components
      • Communication is performed through core.async channels
    • Automatic synchronization of entities’ states
      • An entity is any data loaded into the app that has identity (e.g. :id column)
      • Entities are stored in the EntityDB
      • EntityDB propagates entity state to every place where that entity is displayed in the UI
    • Enforced lifecycle (and memory safety)
      • Automatically load data on route change
      • Automatically clean up stale data on route change
      • Automatically set up event listeners on route change (e.g. listener on the WebSocket)
      • Automatically tear down event listeners on route change
    • Applications are first class citizens
      • Applications can be started and stopped
      • Applications can be passed around
      • Applications can mount sub - applications
    • UI components are decoupled and reusable
      • UI components can declare it’s dependencies
      • Dependencies are injected when the application is started
      • Each component has it’s own context
    • No shared globals
      • Router is bound to the application context
      • App state is bound to the application context
      • Multiple apps can run at the same time, each with it’s own state

    Documentation

    Read the guides or the API docs to find out more about Keechma.

    Name

    Kičma (lat. columna vertebralis) is a Croatian word for backbone / spine.

    Yes, it’s a nod to BackboneJS and SpineJS.

    License

    Copyright © 2016 Mihael Konjevic.

    Distributed under the MIT License.