All notable changes to cljfx will be documented in this file.
run-later
and on-fx-thread
:separator-menu-item
lifecycle (see example)ext-watcher
- watches an IRef. This makes renderer
concept unnecessary.ext-state
- creates and manages a local mutable state. This helps
to decouple independent parts of the cljfx application. This extension
lifecycle is semantically similar to the React useState
hook.ext-effect
- launches a cancellable asynchronous process. This is useful
to do asynchronous side effects in conjunction with ext-state
. This
extension lifecycle is semantically similar to the React useEffect
hook.ext-recreate-on-key-changed
- helper lifecycle that may be composed with
ext-state
to force a local state and view reset.This is a small update in terms of new features, but it represents lessons
learned from 5 years of using cljfx. In the beginning, cljfx strived to be a UI
framework like re-frame: single atom with a data structure that describes the
whole UI state (using renderer
abstraction). This conceptual simplicity has a
heavy trade-off: with a single mutable state, every isolated component, if it
has some state in it, must be a part of a big global thing. Starting with cljfx
1.9.0, it's now possible to have isolated stateful components with their state
stored in the cljfx component tree. Check out new examples showing the features:
:user-data
prop to :node
component:fixed-eye-at-camera-zero
prop to :perspective-camera
component. Since
this value can only be supplied as a constructor arg, it cannot be changed.19.0.2.1
:spot-light
and :directional-light
17.0.2
.:on-iconified-changed
and :on-maximized-changed
stage props.17.0.0.1
.:split-pane/resizable-with-parent
prop to split pane items.Deprecate fx/wrap-async
. This middleware only partially solved the problem of
blocking the UI thread. Since event processing still occurs sequentially on the
agent thread, a long-running event handler would still block other events from
being handled, leading to an unresponsive UI yet again. Another drawback is the
increased complexity introduced by having to carefully manage :fx/sync
flags
(and the fact that they don't even help in all cases, e.g. startDragAndDrop
).
The recommended solution is to handle potentially blocking effects
asynchronously (e.g. via an agent or a future) and to notify the UI about
their completion by dispatching events.
Note that for preserving compatibility fx/wrap-async
is not going to be
removed: it will remain in cljfx forever. Deprecation status means this is no
longer the recommended approach for event handling.
:pseudo-classes
node prop (example).:row-factory
support for :table-view
and :tree-table-view
(see updated e16_cell_factories.clj
example).:date-cell
fx type (thanks @ertugrulcetin!);:date-picker
's :day-cell-factory
up to par with other cell factories.Allow following props to be ifn?
instead of fn?
:
:result-converter
in :dialog
;:cell-value-factory
in :table-column
;:cell-value-factory
in :tree-table-column
.Deprecate fx/sub
in favor of fx/sub-val
and fx/sub-ctx
(thanks @fdeitylink
for kick-starting this process!). I never liked how complected the semantics of
fx/sub
were: it's either root key in a map (which imposes a restriction on
context value to be a map) or function coupled to cljfx (since it has to know
about context). This is why I split fx/sub
responsibilities into 2 different
functions:
fx/sub-val
that subscribes any function to a value wrapped in a context;fx/sub-ctx
that subscribes function to a context itself (hence coupling to
cljfx), that is then subscribes to other functions.See updated Subscriptions and contexts readme section.
Here is how you should migrate your code to benefit from removed complexity:
fx/sub-val
:
;; when subscribing to keywords:
(fx/sub ctx :users)
;; becomes
(fx/sub-val ctx :users)
;; when subscribing to non-invokable keys:
(fx/sub ctx "users")
;; becomes
(fx/sub-val ctx get "users")
The added benefit of fx/sub-val
is ability to provide defaults or look
deeper in the map, since now you can use any function to extract value from
context:
;; added benefit: defaults
(or (fx/sub ctx :users) [])
;; becomes
(fx/sub-val ctx :users [])
;; added benefit: deep lookup
(:name (fx/sub ctx user-by-id id))
;; becomes
(fx/sub-val ctx get-in [:users id :name])
fx/sub-val
:
(fx/sub ctx)
;; becomes
(fx/sub-val ctx identity)
fx/sub-ctx
:
(fx/sub ctx user-by-id 1)
;; becomes
(fx/sub-ctx ctx user-by-id 1)
The added benefit of fx/sub-ctx
is that it allows subscribing to functions
that are not fn?
(e.g. multi-methods).
Note that for preserving compatibility fx/sub
is not going to be removed: it
will remain in cljfx forever. Deprecation status means this is no longer the
recommended approach to using contexts.
:event-filter
/:event-handler
prop lifecyclesnil
item support in cell factoriescljfx.skip-javafx-initialization
java property useful for AOT-compilation:on-value-changed
to Spinner and SpinnerValueFactory props:on-width-changed
and :on-height-changed
scene props:on-focus-owner-changed
scene prop:on-focused-changed
node prop{:-fx-padding '(10 :px)}
→ -fx-padding: 10px
fx/ext-set-env
and fx/ext-get-env
to set and get values in
component tree's environment:event-handler
to Nodes:event-filter
and :event-handler
to Windows:fx/executor
agent option to wrap-async
that allows specifying
custom executor:selected-item
in extra-props lifecycles to be descriptions:event-filter
prop to all nodes (example):on-tabs-changed
prop to :tab-pane
to observe reordering of tabs:on-x-changed
, :on-y-changed
,
:on-width-changed
and :on-height-changed
cljfx.fx.canvas/props
prop map include parent props too:shadow
fx-type keyword pointing to sepia-tone lifecyclefx/ext-many
extension lifecycle that is preferred over fx/wrap-many
renderer middleware:renderer-error-handler
option to fx/create-app
:error-handler
option to fx/create-renderer
:image-view
props: :y
, :fit-width
,
:fit-height
, :preserve-ratio
, :smooth
and :viewport
:clip
prop on Node:on-focused-changed
prop for Window class:owner
prop for Stage and Dialog classes:stylesheets
support in components extending Parent:toggle-group
in ToggleButton's descriptions declaratively (example):install-to
synthetic prop (deprecated!) for Tooltips to allow
declarative tooltip installation to non-control components
(example)fx/unmount-renderer
function to remove watch from *ref
that was
added by fx/mount-renderer
and then tear down component tree:accelerators
prop in scene (example)fx/ext-let-refs
and fx/ext-get-ref
extension lifecycles
that allow decoupling component lifecycle from component treeLifecycle
if :fx.opt/type->lifecycle
returned
falsey value;fx/ext-instance-factory
to create component instances using
factory function;fx/ext-on-instance-lifecycle
to observe created/advanced/deleted
component instances.Initial release
Can you improve this documentation? These fine people already did:
vlaaad, Vlad Protsenko & Vladislav ProtsenkoEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close