sync-form-path
, use form buffer data for params and route paramssync-data-path
, performs get-in on db and merged in to params and
route-paramsstcu/move-keys
for smuggling top-level keys into a nested mapstnu/route
, stnu/params
, stnu/route-name
route helpersNew, simpler validation system. Form flow is now only responsible for
recording input events; it's not responsible for handling the logic of
validating and placing errors in the :errors
key. Forms no longer take a
:validate
key. Instead, they take a :dscr-sub
key which should be a
subscription. The subscription should be multi-arity; when it receivs a form
path, it should describe the form as a whole. When it receives form path and
attr-path, it should describe the attr.
The notion of "description" is a better separation of concerns: the subscription is a view of the form, and it can be any function. It's more flexible than just validation, because sometimes you want to describe the form or attrs beyond just "has error". Sometimes it's "is valid", sometimes it's "upload complete", sometimes it's "username available".
The form field
component helper has been updated to display descriptions.
A new namespace, sweet-tooth.frontend.form.describe
, was added with a
default description sub, ::stored-errors
, which simply return any errors
stored in a form. It also includes reg-describe-validation-sub
, which
creates a subscription that's meant to capture a common pattern of only
showing errors when a user attempts to submit a form. In the future, this ns
will include additional helpers, e.g. one that will display error messages for
an input when it receivs a blur.
renamed on-submit-handler to submit-fn for brevity, plus updated submit-fn to allow for a couple sugared inputs
update signature of route lifecycle guards (:can-exit?
etc) to [db existing-route new-route]
event handler merging for form components. If you supply a handler that has a
framework default, like :on-changed
, the handler default will be passed in
as the second argument and the input's opts as the third
stnf/*-with-route-params
, which was used to add frontend route
params to a sync request. that functionality is now possible with stsf/get {:rules #{merge-route-params}}
. The removed handlers weren't compatible with
the rest of the sync interceptors, like :once
:select
input component has a default :format-read
that relaces nil
with
""
:can-exit?
on existing route and
:can-enter?
on new routesweet-tooth.frontend.nav.utils/routed-entity-form
, helper that returns form
for routed entity:sweet-tooth.frontend.core.flow/remove-entity
handlersweet-tooth.frontend.form.components/form-sync-subs
sweet-tooth.frontend.sync.flow/sync-subs
sweet-tooth.frontend.sync.flow/remove-req
sweet-tooth.frontend.sync.flow/remove-reqs
- filter many reqs by key and value::stsf/remove-reqs
handler that calls above::stsf/remove-reqs-by-route-and-method
creates filters for above to remove
reqs that match sets of methods and route namesstsf/sync-req->sync-event
to avoid awkward composition of generating a
function and immediately applying it, which was necessary with stsf/sync-fx
stsf/sync-req->dispatch
:rules
to sync
options, including:
:once
only sync when there is no existing sync with a :success
status:merge-route-params
merges in route params:when-not-active
only sync if there is not an existing, active sync
(prevents form double submit for example):entity-path
key to sync options. When specified, will look up entity
at path and use it for :route-params
and :params
of a request.nil
sync responsesstsf/sync-fx
to stsf/sync-fx-handler
stsf/sync-once-fx
to stsf/sync-once-fx-handler
:$ctx
reference in sync flow success:checked
instead of :default-checked
so its controlledsweet-tooth.frontend.routes/route
: get a route from the frontend
router::stnf/not-found
routesweet-tooth.frontend.routes.protocol/route
can now take a route namesweet-tooth.frontend.sync.dispatch.ajax/request-methods
now
includes all supported request methodssweet-tooth/sweet-tooth-frontend
to sweet-tooth/frontend
Can now specify :method
as a sync opt, further allowing the
request signature (name) to diverge from the sync calls
Cleaned up form macro, getting rid of unnecessary duplication
added :default-on
to sync opts to eliminate the need to always
have to specify the default handlers whenever you want to have
custom sync handlers. If you need to treat default handlers in some
custom way you can do something like:
{:default-on {:success :skip}
:on {:success [[:first :event]
[::stsf/default-sync-success :$ctx]
[:next :event]]}
But you're probably better off just writing a named handler.
sweet-tooth.frontend.sync.flow/sync-entity-req
: use like
(sync-entity-req :put :comment {:id 1 :content \"comment\"})
. Handles common case of just wanting to sync an
entity by associating the entity into the :route-params
and
:params
sync options.:sweet-tooth.frontend.sync.flow/sync-entity
handler:sweet-tooth.frontend.sync.flow/sync-entity-once
handler:sweet-tooth.frontend.sync.flow/sync-unless-active
handler, now
used by sweet-tooth.frontend.form.flow/submit-form
to prevent
double form submission:sweet-tooth.frontend.nav.flow/navigate-route
handler, allows you
to navigate using route data instead of a path stringCan you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close