Skip to content

The module library of the Tape framework

Notifications You must be signed in to change notification settings

tape-framework/module

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

160 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

README

tape.module

About

  • is extracted from Duct Core

  • see this issue

  • aims to support both Clojure & ClojureScript

This adds a layer of abstraction on top of Integrant. In Integrant, a configuration map is initiated into a running system map:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ config β”œβ”€β”€>β”‚ system β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜

In tape.module, the configuration is initiated twice. The configuration is first initiated into an intermediate configuration, which in turn is initiated into the system:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” init β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” fold β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” init β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ modules-conf β”œβ”€β”€β”€β”€β”€>β”‚ modules-system β”œβ”€β”€β”€β”€β”€>β”‚ system-conf β”œβ”€β”€β”€β”€β”€>β”‚ system β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Keys in a tape.module configuration are expected to initiate into functions that transform a configuration map. There are two broad types: profiles, which merge their value into the configuration, and modules, which provide more complex manipulation.

Usage

Define a module:

my/module.cljs
(ns my.module
  (:require [integrant.code :as ig]
            [tape.module :as module]))

(defmethod ig/init-key ::module [_ _]
  (fn [config]
    (module/merge-configs config {:comp/one x, :comp/two y, ...})))

Use a module in a modules config map:

my/core.cljs
(ns my.core
  (:require [integrant.code :as ig]
            [tape.module :as module]))

(module/load-hierarchy)
(def config {:my.module/module nil, ... <other-modules>})
(def system (-> config module/prep-config ig/init))

A tape_hierarchy.edn file in the root of the src directory can be used to define derivations for modules keys. Always use (module/load-hierarchy) as a first form in your entry point to execute all the derivations.

License

Copyright Β© 2019 James Reeves, clyfe

Distributed under the MIT license.

About

The module library of the Tape framework

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Clojure 100.0%