Home

Awesome

Recollect

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

API Clojars Project

[cumulo/recollect "0.6.4"]
(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:

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