https://github.com/junekelly/clj-omni
Simple, global service locator for Clojure.
https://github.com/junekelly/clj-omni
Last synced: 6 months ago
JSON representation
Simple, global service locator for Clojure.
- Host: GitHub
- URL: https://github.com/junekelly/clj-omni
- Owner: JuneKelly
- License: mit
- Created: 2015-12-05T11:04:47.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-01-09T14:46:33.000Z (over 10 years ago)
- Last Synced: 2025-07-02T20:54:07.862Z (12 months ago)
- Language: Clojure
- Homepage:
- Size: 13.7 KB
- Stars: 6
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# omni
A simple, lightweight, global service locator.
Register values with omni, then retrieve them later.
[](http://clojars.org/omni)
## Install
From [clojars](https://clojars.org/omni):
```clojure
;; in project.clj dependencies
[omni "1.0.0"]
```
## Usage
Require the `omni.core` namespace:
```clojure
(ns whatever.core
(:require [omni.core :as omni]))
...
```
Register a value you want to access throughout your application:
```clojure
(omni/register! :config {:debug false :app-secret "a-terrible-secret" ...})
(omni/register! :db {:connection ...})
```
Retrieve a value (or `nil`):
```clojure
(let [db (omni/want :db)]
...)
```
Insist on getting a value, raise an exception if not found:
```clojure
(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.