[ANN] leaven and bakery - lightweight components for clojure and clojurescript

405 views
Skip to first unread message

Hugo Duncan

unread,
Sep 3, 2014, 4:19:45 PM9/3/14
to clo...@googlegroups.com

leaven [1] is a component library, much like Stuart Sierra's component,
only it works for both clojure and clojurescript and is simpler.

bakery [2] is a library of leaven components, for both clojure and
clojurescript.

An example web app [3] uses httpkit, sente, weasel, storage-atom,
secretary, om-bootstrap, among other libraries.

Leaven doesn't mix system definition with system instantiation. It uses
an explicit system definition, defsystem, that constructs a component
containing sub-components. The dependency ordering between components
is explicit in defsystem. Constructing an instance of the system is
done by creating an instance of the record defsystem defines.

Additional protocols can be implemented on your system in the body of
the defsystem.


[1] https://github.com/palletops/leaven[1]
[2] https://github.com/palletops/bakery[2]
[3] https://github.com/palletops/bakery/example-web-app[3]
signature.asc

blake

unread,
Sep 3, 2014, 4:47:13 PM9/3/14
to clo...@googlegroups.com
I'm not sure your [3] URL works.

Hugo Duncan

unread,
Sep 3, 2014, 4:48:19 PM9/3/14
to clo...@googlegroups.com
signature.asc

Hugo Duncan

unread,
Sep 3, 2014, 5:29:47 PM9/3/14
to clo...@googlegroups.com
signature.asc

blake

unread,
Sep 3, 2014, 6:01:24 PM9/3/14
to clo...@googlegroups.com
Yeah, I worked back to the original to find the web-app. I note that the repo seems to default to develop, which results in a lot of errors when I try to "lein repl" in "example-web-app". (Missing clojars which are, in fact, missing.)

When I switch branch to the master, I don't get those errors, but the process hangs on "Compiling 'target/cljs-test/testable.js", then times out. I tried doing a "lein cljsbuild once" prior, then found that "lein repl" would work.

Thanks!

James Reeves

unread,
Sep 3, 2014, 7:33:44 PM9/3/14
to clo...@googlegroups.com
If I'm understanding right, the main difference between Leaven and Component is that Leaven uses defsystem to specify an explicit start/stop ordering, while Component uses its using function to define dependencies between components, and works out the ordering itself.

Also, while this is a really minor thing, the naming of ILifeCycle kinda bugs me. The "I" prefix is an abbreviation for "Interface", but ILifeCycle is a protocol.

- James

Hugo Duncan

unread,
Sep 3, 2014, 9:53:42 PM9/3/14
to clo...@googlegroups.com

dsblak...@gmail.com writes:

> Yeah, I worked back to the original to find the web-app. I note that the
> repo seems to default to develop, which results in a lot of errors when I
> try to "lein repl" in "example-web-app". (Missing clojars which are, in
> fact, missing.)

A `lein install` at the top level of bakery should allow you to run on
develop.

> When I switch branch to the master, I don't get those errors, but the
> process hangs on "Compiling 'target/cljs-test/testable.js", then times out.
> I tried doing a "lein cljsbuild once" prior, then found that "lein repl"
> would work.

Thanks for the feedback. I've updated the README accordingly.

Hugo
signature.asc

Hugo Duncan

unread,
Sep 3, 2014, 10:09:55 PM9/3/14
to clo...@googlegroups.com

ja...@booleanknot.com writes:

> If I'm understanding right, the main difference between Leaven and
> Component is that Leaven uses *defsystem* to specify an explicit start/stop
> ordering, while Component uses its *using* function to define dependencies
> between components, and works out the ordering itself.

Indeed. The result is a system definition that is open to extension via
other protocols, and that can be instantiated without having to specify
the dependencies between components at the same time, which feels more
natural to me. I could be convinced about adding some sort of
declarative description of inter-component dependencies to defsystem,
but I'm not sure it is really necessary.

Also, the fact it works with clojurescript.

> Also, while this is a really minor thing, the naming of ILifeCycle kinda
> bugs me. The "I" prefix is an abbreviation for "Interface", but ILifeCycle
> is a protocol.

Having used Om a fair bit recently, I was influenced by the naming of
the protocols there.

Hugo
signature.asc

Julio Barros

unread,
Sep 3, 2014, 10:39:36 PM9/3/14
to clo...@googlegroups.com
Thanks Hugo! I was just wishing for something like this for ClojureScript. I look forward to checking it out.

Julio
Reply all
Reply to author
Forward
0 new messages