Liking cljdoc? Tell your friends :D

Recollect

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

API Clojars Project

[cumulo/recollect "0.6.0-a1"]
(recollect.twig/deftwig twig-name [param] body)
(recollect.twig/clear-twig-caches!)
(recollect.twig/new-twig-loop!)
(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.

For function arguments in deftwig, changes are ignored.

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