mhuebert / instaparse-live

Build parsers in your browser using instaparse-cljs (ClojureScript/Reagent)
http://instaparse-live.matt.is
43 stars 2 forks source link

Optimize reactive computation #5

Closed aengelberg closed 9 years ago

aengelberg commented 9 years ago

Currently, if only the parse input is changed, the grammar is needlessly recomputed due to the nature of the reagent flow.

There should be a way in reagent to pull from both atoms one at a time (in separate components) in a way that only requires re-computing the parser when the grammar is edited.

mhuebert commented 9 years ago

Yeah I'll look at this. Maybe I can just memorize the parse function. Or have the atom that is dereferenced in the output component store the parsed grammar rather than the grammar text.

On Thursday, June 11, 2015, aengelberg notifications@github.com wrote:

Currently, if only the parse input is changed, the grammar is needlessly recomputed due to the nature of the reagent flow.

There should be a way in reagent to pull from both atoms one at a time (in separate components) in a way that only requires re-computing the parser when the grammar is edited.

— Reply to this email directly or view it on GitHub https://github.com/mhuebert/instaparse-live/issues/5.

mhuebert commented 9 years ago

Fixed in 0f2e925a756339b5e06756f92d30433a58e6790c with a custom memoize function (only remembers the last args/result)