This project is part of the @thi.ng/umbrella monorepo.
This package provides a single
updateDOM function, a side-effecting &
stateful transducer which receives
component trees, diffs each against the previous value and applies any
required changes to the browser DOM, starting at given root element. By
default, incoming values are first normalized using @thi.ng/hdom's
normalizeTree() function. See hdom's
for more details.
hydrate option is given, the first received tree is only used
to inject event listeners and initialize components with lifecycle
init() methods and expects an otherwise identical pre-existing DOM.
All succeeding trees are diffed then as usual.
This transducer is primarily intended for @thi.ng/rstream-based dataflow graphs, where it can be used as final leaf subscription / stream transformer to reflect UI changes back to the user, without using the usual RAF update loop used by @thi.ng/hdom by default. In this setup, DOM updates will only be performed if the stream this transducer is attached to receives new values (i.e. hdom component trees).
Please also see the following hdom references for further details:
yarn add @thi.ng/transducers-hdom
The below example is also available in the /examples directory.
;;;// root component function;// click stream (click counter);// stream combinatorrs.sync.transform// transform into hdom componenttx.mapapp,// apply as DOMupdateDOM;// kick offclickStream.next0;
- Karsten Schmidt
© 2018 Karsten Schmidt // Apache Software License 2.0