(db-effects atm)
Effects for updating state in an atom.
The effects are:
:update
similar to update
except instead of a keypath, takes a more generic path.
example: [:update $path inc]
:set
sets the value given a $path
example: [:set $path value]
:delete
deletes value at $path
example: [:delete $path]
Effects for updating state in an atom. The effects are: `:update` similar to `update` except instead of a keypath, takes a more generic path. example: `[:update $path inc]` `:set` sets the value given a $path example: `[:set $path value]` `:delete` deletes value at $path example: `[:delete $path]`
(defeffect type args & body)
Define an effect.
defeffect
is a macro that does 3 things:
type
. type
should be a keyword and since it is registered globally, should be namespacedeffect-*type*
where type is the name of the type keyword. This can be useful if you want to be able to use your effect functions in isolationdispatch
The arglist for dispatch!
is [type & args]
. Calling dispatch!
will invoke the effect of type
with args
.
The role of dispatch!
is to allow effects to define themselves in terms of other effects. Effects should not be called directly because while the default for an application is to use all the globally defined effects, this can be overridden for testing, development, or otherwise.
example:
(defeffect ::increment-number [$num] (dispatch! :update $num inc))
Define an effect. `defeffect` is a macro that does 3 things: 1) It registers a global effect handler of `type`. `type` should be a keyword and since it is registered globally, should be namespaced 2) It will define a var in the current namespace of `effect-*type*` where *type* is the name of the type keyword. This can be useful if you want to be able to use your effect functions in isolation 3) It will implicitly add an additional argument as the first parameter named `dispatch` The arglist for `dispatch!` is `[type & args]`. Calling `dispatch!` will invoke the effect of `type` with `args`. The role of `dispatch!` is to allow effects to define themselves in terms of other effects. Effects should not be called directly because while the default for an application is to use all the globally defined effects, this can be overridden for testing, development, or otherwise. example: (defeffect ::increment-number [$num] (dispatch! :update $num inc))
(defui ui-name & fdecl)
Define a component.
The arguments for a component must take the form (defui my-component [ & {:keys [arg1 arg2 ...]}])
Define a component. The arguments for a component must take the form (defui my-component [ & {:keys [arg1 arg2 ...]}])
(run-ui ui-var)
(run-ui ui-var initial-state)
(run-ui ui-var initial-state handler)
(run-ui ui-var initial-state handler options)
ui-var
The var for a component
initial-state
The initial state of the component to run or an atom that contains the initial state.
handler
The effect handler for your UI. The handler
will be called with all effects returned by the event handlers of your ui.
If handler
is nil or an arity that doesn't specify handler
is used, then a default handler using all of the globally defined effects from defeffect
will be used. In addition to the globally defined effects the handler will provide 3 additional effects:
:update
similar to update
except instead of a keypath, takes a more generic path.
example: [:update $path inc]
:set
sets the value given a $path
example: [:set $path value]
:delete
deletes value at $path
example: [:delete $path]
return value: the state atom used by the ui.
The only difference between run-ui
and run-ui-sync
is that run-ui-sync
will wait until the window is closed before returning.
options
options is a map of options that get passed to the underlying graphics platform. see membrane.skia/run
or membrane.webgl/run
for more info.
`ui-var` The var for a component `initial-state` The initial state of the component to run or an atom that contains the initial state. `handler` The effect handler for your UI. The `handler` will be called with all effects returned by the event handlers of your ui. If `handler` is nil or an arity that doesn't specify `handler` is used, then a default handler using all of the globally defined effects from `defeffect` will be used. In addition to the globally defined effects the handler will provide 3 additional effects: `:update` similar to `update` except instead of a keypath, takes a more generic path. example: `[:update $path inc]` `:set` sets the value given a $path example: `[:set $path value]` `:delete` deletes value at $path example: `[:delete $path]` return value: the state atom used by the ui. The only difference between `run-ui` and `run-ui-sync` is that `run-ui-sync` will wait until the window is closed before returning. `options` options is a map of options that get passed to the underlying graphics platform. see `membrane.skia/run` or `membrane.webgl/run` for more info.
(run-ui-sync ui-var)
(run-ui-sync ui-var initial-state)
(run-ui-sync ui-var initial-state handler)
(run-ui-sync ui-var initial-state handler options)
ui-var
The var for a component
initial-state
The initial state of the component to run or an atom that contains the initial state.
handler
The effect handler for your UI. The handler
will be called with all effects returned by the event handlers of your ui.
If handler
is nil or an arity that doesn't specify handler
is used, then a default handler using all of the globally defined effects from defeffect
will be used. In addition to the globally defined effects the handler will provide 3 additional effects:
:update
similar to update
except instead of a keypath, takes a more generic path.
example: [:update $path inc]
:set
sets the value given a $path
example: [:set $path value]
:delete
deletes value at $path
example: [:delete $path]
return value: the state atom used by the ui.
The only difference between run-ui
and run-ui-sync
is that run-ui-sync
will wait until the window is closed before returning.
options
options is a map of options that get passed to the underlying graphics platform. see membrane.skia/run
or membrane.webgl/run
for more info.
`ui-var` The var for a component `initial-state` The initial state of the component to run or an atom that contains the initial state. `handler` The effect handler for your UI. The `handler` will be called with all effects returned by the event handlers of your ui. If `handler` is nil or an arity that doesn't specify `handler` is used, then a default handler using all of the globally defined effects from `defeffect` will be used. In addition to the globally defined effects the handler will provide 3 additional effects: `:update` similar to `update` except instead of a keypath, takes a more generic path. example: `[:update $path inc]` `:set` sets the value given a $path example: `[:set $path value]` `:delete` deletes value at $path example: `[:delete $path]` return value: the state atom used by the ui. The only difference between `run-ui` and `run-ui-sync` is that `run-ui-sync` will wait until the window is closed before returning. `options` options is a map of options that get passed to the underlying graphics platform. see `membrane.skia/run` or `membrane.webgl/run` for more info.
(top-level-ui & {:keys [extra state body arg-names defaults handler context]})
(top-level-ui &
{:keys [extra state body arg-names defaults handler context]
:as m-38026})
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close