I've been working on Eucalypt, a frontend library for building small web apps with Squint-ClojureScript. It features a Reagent-compatable-ish API. I'm not implementing the full Reagent API, just a useful subset, and so I was interested in which parts of Reagent are most used.
no r/track? -- HN User
To figure this out I used GitHub as a data source, performing searches for common patterns and counting up totals.
Raw results
--- Reagent API Usage ---
require reagent.core 7656
atom 6269
render 3581
require reagent.dom 1664
with-let 1114
:dangerouslySetInnerHTML 1036
cursor 670
track 170
wrap 94
track! 65
reaction 60
unsafe-html 16
These numbers come with caveats. Some API calls are inherently going to occur more frequently than others in a given codebase, names may be aliased in a way I didn't consider, and these are public code-bases only. I think they give interesting ballpark numbers anyway.
You can find the scripts I used on GitHub: https://github.com/chr15m/report-reagent-api-usage
My hunch that r/atom and r/render are the critical pieces of this API seem to be correct. Other parts of the API are called less often. I think for the Eucalypt API I will focus on cursor and above and I won't implement the less-used functions. Keeping the API concise adds to the goal of the library being "small" in several ways:
- Small artifact sizes produced.
- Small code size of the library itself.
- Small API.
- Small set of concerns.
At the moment I am porting the Preact test suite over to Eucalypt. If I can get all of those tests passing I'll probably cut a version one-point-oh.