Skip to content

JuneKelly/clj-omni

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

omni

A simple, lightweight, global service locator. Register values with omni, then retrieve them later.

Clojars Project

Install

From clojars:

;; in project.clj dependencies
[omni "1.0.0"]

Usage

Require the omni.core namespace:

(ns whatever.core
  (:require [omni.core :as omni]))
...

Register a value you want to access throughout your application:

(omni/register! :config {:debug false :app-secret "a-terrible-secret" ...})
(omni/register! :db     {:connection ...})

Retrieve a value (or nil):

(let [db (omni/want :db)]
  ...)

Insist on getting a value, raise an exception if not found:

(let [db (omni/need! :db)]
  ...)

Why use Omni instead of Component?

Because Omni is massively simpler, and doesn't require full-app buy-in. Just shove things into omni, and pluck them out later.

I've got nothing against Component, it's a great tool, but sometimes you really just want your "system" to be a global lookup table, without any other baggage.

License

Copyright © 2015 Shane Kilkelly

Distributed under the MIT license.

About

Simple, global service locator for Clojure.

Resources

License

Stars

Watchers

Forks

Packages