Liking cljdoc? Tell your friends :D

Recollect

Cached rendering and diff/patch library designed for Cumulo project.

API Clojars Project

[cumulo/recollect "0.4.3"]
(recollect.macros/deftwig twig-name [param] body)
(recollect.twig/render-twig twig-data old-data-twig)
(recollect.twig/conceal data-twig)
(recollect.diff/diff-twig a b {:key :id})
(recollect.diff/patch-twig a changes)

Terms:

  • Twig: data wrapped with a renderer to caching purpose
  • :key: to help diff maps

Purpose

Rendering data tree and doing diffing would be slow. It's a simlar to the problem of React DOM diffing.

This library is using the algorithm developed in Respo DOM diffing. It's like data rendering, with keeps reusing last result of data tree.

It's not tested yet, but is trying to trade memory and performance with caching.

Diff Operations

numbernamemeaning
0tree-op-assocassoc-in
1tree-op-dissocdissoc-in
2tree-op-vec-appendappend items to vector
3tree-op-vec-droppop items from vector
4tree-op-set-spliceremove and add to set
5tree-op-seq-spliceremove and add to sequence

For vectors, data is supposed to be manipulated from the tail. Items in the new vector are mapped to its old ones by index.

For sequences, unchanged values since the tail is kept. Changed elements in the front will be replaced directly.

Related

For record parsing http://stackoverflow.com/a/29133350/883571

Develop

Workflow https://github.com/mvc-works/calcit-workflow

To run tests:

yarn test

License

MIT

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close