A simple, lightweight, global service locator. Register values with omni, then retrieve them later.
From clojars:
;; in project.clj dependencies
[omni "1.0.0"]
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)]
...)
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.
Copyright © 2015 Shane Kilkelly
Distributed under the MIT license.