user
component, the user
interface was also created.interface
and what is it good for?interface
that often lives in one but sometimes several namespaces within a component. It defines a number of def
, defn
or defmacro
statements which forms the contract that it exposes to other components and bases.def
, defn
and defmacro
definitions, which is something the tool helps us with.user
containing the functions fun1
and fun2
and that two components "implement" this interface, e.g:interface
namespace in a component, but it's also possible to divide the interface into several sub namespaces. To do so we first create an interface
package (directory) with the name interface
at the root and then we put the sub namespaces in there.util
component in the Polylith repository does that, by dividing its util interface into several sub namespaces:spec
sub namespace, which we have an example of in the RealWorld example app, where the article
component also has an interface.spec sub interface.def
and defmacro
statements in the interface. There is no magic here, just include the definitions you want, like this:defmacro
definition can look like this:sell [car]
, while the implementing function can do the destructuring, e.g. sell [{:keys [model type color]}]
which sometimes can improve the readability.nil
.&
as a vector
to the implementing function.test
directory. Only the code under the src
directory is restricted to only access the interface
namespace. The check is performed when running the check
, info
or test
command.function
in two components that implement the same interface, all definitions must be function
. The same goes for macros
. The reason for this restriction is that functions are composable, but macros are not, which could otherwise cause problems.interface
namespace name can be changed in :interface-ns
in ./workspace.edn
. Here are a few reasons why we would like to do that:.cljc
files. Because interface
is a reserved word in ClojureScript, this may cause problems.interface
is a reserved word.interface
name is that it communicates what it does.