DrSensor / nusa

incremental runtime that bring both simplicity and power into webdev (buildless, cross-language, data-driven)
MIT License
4 stars 0 forks source link

Snapshot and Iterate class instances #40

Open DrSensor opened 1 year ago

DrSensor commented 1 year ago

Warning function generator might not fast enough so I'm using await iterate.resume instead of yield (need a benchmark to prove this)

Most likely await-ing is not optimal since it require async keyword. This make iterate() switch into concurrent iteration logic if it use async function although await iterate.resume doesn't need to be queued into microtask. šŸ’” Alternative: iterate.yield and iterate.resume()

Note await iterate.continue will render update the current changes from start/continued index to awaited index

Note snapshot and iterate for WASM only support module-path instead of module instance since it still unknown how import ? from "module.wasm" assert {type:"wasm"} will be executed

šŸ“š References:

DrSensor commented 1 year ago

Shortcut to create a new Controller for specific iteration

const ctl = new iterate
  .for(Counter, (index, {count}) => { ... })

The controller is persisted and you need to explicitly ctl.run() the iteration as many times as you want.