React-agnostic compile-time helpers extracted from the defsc macro. These functions run at macroexpansion
time (CLJ only) and are used to validate and rewrite the query, ident, and initial-state options of a
stateful component definition.
Errors are reported via an injectable error function so that this namespace does not depend on
cljs.analyzer. By default default-macro-error returns an ex-info. The defsc macro rebinds
*macro-error* to cljs.analyzer/error so that CLJS compilation produces nice analyzer errors.
React-agnostic compile-time helpers extracted from the `defsc` macro. These functions run at macroexpansion time (CLJ only) and are used to validate and rewrite the query, ident, and initial-state options of a stateful component definition. Errors are reported via an injectable error function so that this namespace does not depend on `cljs.analyzer`. By default `default-macro-error` returns an `ex-info`. The `defsc` macro rebinds `*macro-error*` to `cljs.analyzer/error` so that CLJS compilation produces nice analyzer errors.
The function used to construct (not throw) an error from (env msg). Rebound by defsc so that CLJS
compilation produces analyzer errors. Defaults to default-macro-error.
The function used to construct (not throw) an error from `(env msg)`. Rebound by `defsc` so that CLJS compilation produces analyzer errors. Defaults to `default-macro-error`.
(-legal-keys query)Find the legal keys in a query. NOTE: This is at compile time, so the get-query calls are still embedded (thus cannot use the AST)
Find the legal keys in a query. NOTE: This is at compile time, so the get-query calls are still embedded (thus cannot use the AST)
(build-and-validate-initial-state-map env
sym
initial-state
legal-keys
children-by-query-key)(build-ident env
thissym
propsarg
{:keys [method template keyword]}
is-legal-key?)Builds the ident form. If ident is a vector, then it generates the function and validates that the ID is in the query. Otherwise, if ident is of the form (ident [this props] ...) it simply generates the correct entry in defsc without error checking.
Builds the ident form. If ident is a vector, then it generates the function and validates that the ID is in the query. Otherwise, if ident is of the form (ident [this props] ...) it simply generates the correct entry in defsc without error checking.
(build-initial-state env
sym
{:keys [template method]}
legal-keys
query-template-or-method)(build-query-forms env class thissym propargs {:keys [template method]})Validate that the property destructuring and query make sense with each other.
Validate that the property destructuring and query make sense with each other.
(build-raw-initial-state env method)Given an initial state form that is a list (function-form), simple copy it into the form needed by defsc.
Given an initial state form that is a list (function-form), simple copy it into the form needed by defsc.
(children-by-prop query)Part of Defsc macro implementation. Calculates a map from join key to class (symbol).
Part of Defsc macro implementation. Calculates a map from join key to class (symbol).
(compile-time-query->checkable query)Try to simplify the compile-time query (as seen by the macro)
to something that EQL can check ((get-query ..) => a made-up vector).
Returns nil if this is not possible.
Try to simplify the compile-time query (as seen by the macro) to something that EQL can check (`(get-query ..)` => a made-up vector). Returns nil if this is not possible.
(default-macro-error env msg)Default macro error function. Returns (does not throw) an ex-info describing msg, including line/column
information from env when available.
Default macro error function. Returns (does not throw) an `ex-info` describing `msg`, including line/column information from `env` when available.
(is-link? query-element)Returns true if the given query element is a link query like [:x '_].
Returns true if the given query element is a link query like [:x '_].
(macro-error env msg)Returns an exception (via *macro-error*) for the given macro env and message msg. Does not throw.
Returns an exception (via `*macro-error*`) for the given macro `env` and message `msg`. Does not throw.
(replace-and-validate-fn env sym external-args user-arity fn-form)(replace-and-validate-fn env
sym
external-args
user-arity
fn-form
user-known-sym)Replace the first sym in a list (the function name) with the given symbol.
env - the macro &env sym - The symbol that the lambda should have external-args - A sequence of arguments that the user should not include, but that you want to be inserted in the external-args by this function. user-arity - The number of external-args the user should supply (resulting user-arity is (count external-args) + user-arity). fn-form - The form to rewrite sym - The symbol to report in the error message (in case the rewrite uses a different target that the user knows).
Replace the first sym in a list (the function name) with the given symbol. env - the macro &env sym - The symbol that the lambda should have external-args - A sequence of arguments that the user should not include, but that you want to be inserted in the external-args by this function. user-arity - The number of external-args the user should supply (resulting user-arity is (count external-args) + user-arity). fn-form - The form to rewrite sym - The symbol to report in the error message (in case the rewrite uses a different target that the user knows).
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |