(build f x)
(build f x m)
Builds an Om component. Takes an IRender/IRenderState instance returning function f, a value, and an optional third argument which may be a map of build specifications.
f - is a function of 2 or 3 arguments. The first argument can be any value and the second argument will be the owning pure node. If a map of options m is passed in this will be the third argument. f must return at a minimum an IRender or IRenderState instance, this instance may implement other React life cycle protocols.
x - any value
m - a map the following keys are allowed:
:key - a keyword that should be used to look up the key used by React itself when rendering sequential things. :react-key - an explicit react key :fn - a function to apply to the data before invoking f. :init-state - a map of initial state to pass to the component. :state - a map of state to pass to the component, will be merged in. :opts - a map of values. Can be used to pass side information down the render tree. :descriptor - a JS object of React methods, will be used to construct a React class per Om component function encountered. defaults to pure-descriptor.
Example:
(build list-of-gadgets x {:init-state {:event-chan ... :narble ...}})
Builds an Om component. Takes an IRender/IRenderState instance returning function f, a value, and an optional third argument which may be a map of build specifications. f - is a function of 2 or 3 arguments. The first argument can be any value and the second argument will be the owning pure node. If a map of options m is passed in this will be the third argument. f must return at a minimum an IRender or IRenderState instance, this instance may implement other React life cycle protocols. x - any value m - a map the following keys are allowed: :key - a keyword that should be used to look up the key used by React itself when rendering sequential things. :react-key - an explicit react key :fn - a function to apply to the data before invoking f. :init-state - a map of initial state to pass to the component. :state - a map of state to pass to the component, will be merged in. :opts - a map of values. Can be used to pass side information down the render tree. :descriptor - a JS object of React methods, will be used to construct a React class per Om component function encountered. defaults to pure-descriptor. Example: (build list-of-gadgets x {:init-state {:event-chan ... :narble ...}})
(build-all f xs)
(build-all f xs m)
Build a sequence of components. f is the component constructor function, xs a sequence of values, and m a map of options the same as provided to om.core/build.
Build a sequence of components. f is the component constructor function, xs a sequence of values, and m a map of options the same as provided to om.core/build.
(commit! cursor korks f)
EXPERIMENTAL: Like transact! but does not schedule a re-render or create a transact event.
EXPERIMENTAL: Like transact! but does not schedule a re-render or create a transact event.
(component & body)
Sugar over reify for quickly putting together components that only need to implement om.core/IRender and don't need access to the owner argument.
Sugar over reify for quickly putting together components that only need to implement om.core/IRender and don't need access to the owner argument.
(detach-root target)
Given a DOM target remove its render loop if one exists.
Given a DOM target remove its render loop if one exists.
(get-node owner)
(get-node owner name)
A helper function to get at React DOM refs. Given a owning pure node extract the DOM ref specified by name.
A helper function to get at React DOM refs. Given a owning pure node extract the DOM ref specified by name.
(get-props x)
(get-props x korks)
Given an owning Pure node return the Om props. Analogous to React component props.
Given an owning Pure node return the Om props. Analogous to React component props.
(get-ref owner name)
A helper function to get at React refs. Given an owning pure node extract the ref specified by name.
A helper function to get at React refs. Given an owning pure node extract the ref specified by name.
(get-render-state owner)
(get-render-state owner korks)
Takes a pure owning component and an optional key or sequential list of keys and returns a property in the component local state if it exists. Always returns the rendered state, not the pending state.
Takes a pure owning component and an optional key or sequential list of keys and returns a property in the component local state if it exists. Always returns the rendered state, not the pending state.
(get-shared owner)
(get-shared owner korks)
Takes an owner and returns a map of global shared values for a render loop. An optional key or sequence of keys may be given to extract a specific value.
Takes an owner and returns a map of global shared values for a render loop. An optional key or sequence of keys may be given to extract a specific value.
(get-state owner)
(get-state owner korks)
Returns the component local state of an owning component. owner is the component. An optional key or sequence of keys may be given to extract a specific value. Always returns pending state.
Returns the component local state of an owning component. owner is the component. An optional key or sequence of keys may be given to extract a specific value. Always returns pending state.
(-get-render-state this)
(-get-render-state this ks)
(-unlisten! x key)
(-listen! x key tx-listen)
(-notify! x tx-data root-cursor)
(-refresh-deps! this)
(-add-dep! this c)
(-get-deps this)
(-remove-dep! this c)
(-get-queue this)
(-queue-render! this c)
(-empty-queue! this)
(-set-property! this id p val)
(-remove-property! this id p)
(-get-property this id p)
(-remove-properties! this id)
(-set-state! this val render)
(-set-state! this ks val render)
(mounted? owner)
Return true if the backing React component is mounted into the DOM.
Return true if the backing React component is mounted into the DOM.
(observe c ref)
Given a component and a reference cursor have the component observe the reference cursor for any data changes.
Given a component and a reference cursor have the component observe the reference cursor for any data changes.
(ref-cursor cursor)
Given a cursor return a reference cursor that inherits all of the properties and methods of the cursor. Reference cursors may be observed via om.core/observe.
Given a cursor return a reference cursor that inherits all of the properties and methods of the cursor. Reference cursors may be observed via om.core/observe.
(refresh! owner)
Utility to re-render an owner.
Utility to re-render an owner.
(render-all)
(render-all state)
Force a render of all roots. Usage of this function is almost never recommended.
Force a render of *all* roots. Usage of this function is almost never recommended.
(root f
value
{:keys [target tx-listen path instrument descriptor adapt raf]
:as options})
Take a component constructor function f, value an immutable tree of associative data structures optionally an wrapped in an IAtom instance, and a map of options and installs an Om/React render loop.
f must return an instance that at a minimum implements IRender or IRenderState (it may implement other React life cycle protocols). f must take at least two arguments, the root cursor and the owning pure node. A cursor is just the original data wrapped in an ICursor instance which maintains path information. Only one root render loop allowed per target element. om.core/root is idempotent, if called again on the same target element the previous render loop will be replaced.
Options may also include any key allowed by om.core/build to customize f. In addition om.core/root supports the following special options:
:target - (required) a DOM element. :shared - data to be shared by all components, see om.core/get-shared :tx-listen - a function that will listen in in transactions, should take 2 arguments - the first a map containing the path, old and new state at path, old and new global state, and transaction tag if provided. :instrument - a function of three arguments that if provided will intercept all calls to om.core/build. This function should correspond to the three arity version of om.core/build. :adapt - a function to adapt the root cursor :raf - override requestAnimationFrame based rendering. If false setTimeout will be use. If given a function will be invoked instead.
Example:
(root (fn [data owner] ...) {:message :hello} {:target js/document.body})
Take a component constructor function f, value an immutable tree of associative data structures optionally an wrapped in an IAtom instance, and a map of options and installs an Om/React render loop. f must return an instance that at a minimum implements IRender or IRenderState (it may implement other React life cycle protocols). f must take at least two arguments, the root cursor and the owning pure node. A cursor is just the original data wrapped in an ICursor instance which maintains path information. Only one root render loop allowed per target element. om.core/root is idempotent, if called again on the same target element the previous render loop will be replaced. Options may also include any key allowed by om.core/build to customize f. In addition om.core/root supports the following special options: :target - (required) a DOM element. :shared - data to be shared by all components, see om.core/get-shared :tx-listen - a function that will listen in in transactions, should take 2 arguments - the first a map containing the path, old and new state at path, old and new global state, and transaction tag if provided. :instrument - a function of three arguments that if provided will intercept all calls to om.core/build. This function should correspond to the three arity version of om.core/build. :adapt - a function to adapt the root cursor :raf - override requestAnimationFrame based rendering. If false setTimeout will be use. If given a function will be invoked instead. Example: (root (fn [data owner] ...) {:message :hello} {:target js/document.body})
(root-cursor atom)
Given an application state atom return a root cursor for it.
Given an application state atom return a root cursor for it.
(set-state! owner v)
(set-state! owner korks v)
Takes a pure owning component, a sequential list of keys and value and sets the state of the component. Conceptually analagous to React setState. Will schedule an Om re-render.
Takes a pure owning component, a sequential list of keys and value and sets the state of the component. Conceptually analagous to React setState. Will schedule an Om re-render.
(set-state-nr! owner v)
(set-state-nr! owner korks v)
EXPERIMENTAL: Same as set-state! but does not trigger re-render.
EXPERIMENTAL: Same as set-state! but does not trigger re-render.
(transact! cursor f)
(transact! cursor korks f)
(transact! cursor korks f tag)
Given a tag, a cursor, an optional list of keys ks, mutate the tree at the path specified by the cursor + the optional keys by applying f to the specified value in the tree. An Om re-render will be triggered.
Given a tag, a cursor, an optional list of keys ks, mutate the tree at the path specified by the cursor + the optional keys by applying f to the specified value in the tree. An Om re-render will be triggered.
(update! cursor v)
(update! cursor korks v)
(update! cursor korks v tag)
Like transact! but no function provided, instead a replacement value is given.
Like transact! but no function provided, instead a replacement value is given.
(update-state! owner f)
(update-state! owner korks f)
Takes a pure owning component, a sequential list of keys and a function to transition the state of the component. Conceptually analagous to React setState. Will schedule an Om re-render.
Takes a pure owning component, a sequential list of keys and a function to transition the state of the component. Conceptually analagous to React setState. Will schedule an Om re-render.
(update-state-nr! owner f)
(update-state-nr! owner korks f)
EXPERIMENTAL: Same as update-state! but does not trigger re-render.
EXPERIMENTAL: Same as update-state! but does not trigger re-render.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close