2.9 KiB
2.9 KiB
The re-frame API
Orientation:
- The API is provided by re-frame.core which means:
- it will be worth your while to browse this namespace sometime
- to use re-frame, you'll need to
require
it
- The API is small. Writing an app, you'll be using less than 10 API functions. Maybe just 5.
- There's no auto-generated docs because of this problem but the links below take you to the doc strings of often-used API functions.
Doc Strings For API Functions
The core API consists of:
Occasionally, you'll need to use:
And, finally, there are builtin Interceptors which are useful:
Built-in Effect Handlers
The following built-in effects are part of the API:
:dispatch-later
dispatch
one or more events after given delays. Expects a collection
of maps with two keys: :ms
and :dispatch
usage:
{:dispatch-later [{:ms 200 :dispatch [:event-id "param"]}
{:ms 100 :dispatch [:also :this :in :100ms]}]}
Which means: in 200ms do this: (dispatch [:event-id "param"])
and in 100ms ...
:dispatch
dispatch
one event. Expects a single vector.
usage:
{:dispatch [:event-id "param"] }
:dispatch-n
dispatch
more than one event. Expects a collection events.
usage:
{:dispatch-n (list [:do :all] [:three :of] [:these])}
:deregister-event-handler
removes a previously registered event handler. Expects either a single id ( typically a keyword), or a seq of ids.
usage:
{:deregister-event-handler :my-id)}
or:
{:deregister-event-handler [:one-id :another-id]}
:db
reset! app-db with a new value. Expects a map.
usage:
{:db {:key1 value1 :key2 value2}}
Previous: First Code Walk-Through Up: Index Next: Mental Model Omnibus