The Rollup plugin provides a good example of integrating calculations from a number of pages.
in Rollup plugin
Rollup displays each row three times. First with original data, then with recomputed data, and finally with a new rank computed after all rows have been recomputed.
attach "Material Summary" for each row display in current form initiate recalculation, then display in recomputed form if no more to recalculate rank order results by total score display in recomputed form with new rank emit replacement for "Material Summary"
Recalculation involves fetching a page and then interpreting every Method plugin on that page.
wait for time to fetch, then load the Method plugin, then fetch the desired page, then for every method in the page evaluate the method with the plugin
in Method plugin
The Method plugin offers an eval function in addition to the usual emit and bind. Eval begins dispatching computations without any of the usual dom setup.
dispatch each line, then callback with newly computed values
Dispatch is coded as tail-recursion via callbacks though in its current form no asynchronous computation occurs.
callback when no lines remaining switch on next line case /literal/ ... case /variable/ ... case /function/ ... accumulate results recurse for remaining lines
Results
Each method evaluation takes input binding and produces output bindings. The /variable/ and /function/ cases add values to the output bindings.
The caller of eval are expected to merge outputs with previous inputs to produce inputs for subsequent evaluations.
Values may be bound to numbers, strings or objects. One suggestion is to treat bound values as promises. See Simple Promise.