Liking cljdoc? Tell your friends :D

com.walmartlabs.lacinia.vendor.useful.experimental.delegate


canonical-nameclj

(canonical-name sym)

Resolve a symbol in the current namespace; but intead of returning its value, return a canonical name that can be used to name the same thing in any namespace.

Resolve a symbol in the current namespace; but intead of returning its value,
return a canonical name that can be used to name the same thing in any
namespace.
raw docstring

delegating-defrecordcljmacro

(delegating-defrecord cname [& fields] delegate-map & deftype-args)

Like delegating-deftype, but creates a defrecod body instead of a deftype.

Like delegating-deftype, but creates a defrecod body instead of a deftype.
raw docstring

delegating-deftypecljmacro

(delegating-deftype cname [& fields] delegate-map & deftype-args)

Shorthand for defining a new type with deftype, which delegates the methods you name to some other object or objects. Delegates are usually a member field, but can be any expression: the expression will be evaluated every time a method is delegated. The delegate object (or expression) will be type-hinted with the type of the interface being delegated.

The delegate-map argument should be structured like: {object-to-delegate-to {Interface1 [(method1 []) (method2 [foo bar baz])] Interface2 [(otherMethod [other])]}, another-object {Interface1 [(method3 [whatever])]}}.

This will cause your deftype to include an implementation of Interface1.method1 which does its work by forwarding to (.method1 object-to-delegate-to), and likewise for the other methods. Arguments will be forwarded on untouched, and you should not include a this parameter. Note especially that you can have methods from Interface1 implemented by delegating to multiple objects if you choose, and can also include custom implementations for the remaining methods of Interface1 if you have no suitable delegate.

Arguments after delegate-map are as with deftype, although if deftype ever has options defined for it, delegating-deftype may break with them.

Shorthand for defining a new type with deftype, which delegates the methods you name to some
other object or objects. Delegates are usually a member field, but can be any expression: the
expression will be evaluated every time a method is delegated. The delegate object (or
expression) will be type-hinted with the type of the interface being delegated.

The delegate-map argument should be structured like:
  {object-to-delegate-to {Interface1 [(method1 [])
                                      (method2 [foo bar baz])]
                          Interface2 [(otherMethod [other])]},
   another-object {Interface1 [(method3 [whatever])]}}.

This will cause your deftype to include an implementation of Interface1.method1 which does its
work by forwarding to (.method1 object-to-delegate-to), and likewise for the other
methods. Arguments will be forwarded on untouched, and you should not include a `this`
parameter. Note especially that you can have methods from Interface1 implemented by delegating
to multiple objects if you choose, and can also include custom implementations for the remaining
methods of Interface1 if you have no suitable delegate.

Arguments after `delegate-map` are as with deftype, although if deftype ever has options defined
for it, delegating-deftype may break with them.
raw docstring

delegating-reifycljmacro

(delegating-reify delegate-map & reify-args)

Like delegating-deftype, but creates a reify body instead of a deftype.

Like delegating-deftype, but creates a reify body instead of a deftype.
raw docstring

emit-deftype-specsclj

(emit-deftype-specs specs)

Given a map returned by aggregate, spit out a flattened deftype body.

Given a map returned by aggregate, spit out a flattened deftype body.
raw docstring

parse-deftype-specsclj

(parse-deftype-specs decls)

Given a mess of deftype specs, possibly with classes/interfaces specified multiple times, collapse it into a map like {interface => (method1 method2...)}. Needed because core.deftype only allows specifying a class ONCE, so our delegating versions would clash with client's custom methods.

Given a mess of deftype specs, possibly with classes/interfaces specified multiple times,
collapse it into a map like {interface => (method1 method2...)}.
Needed because core.deftype only allows specifying a class ONCE, so our delegating versions would
clash with client's custom methods.
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close