Cooperative Scheduling with Yield()

Compare a batch loop with and without lofigui.Yield()

What this demonstrates

  • With Yield()time.Sleep(1ms) in WASM suspends the Go runtime, letting the browser repaint. Output streams in progressively.
  • Without Yield()runtime.Gosched() only yields between Go goroutines, NOT to the browser. The page freezes then all output appears at once.

With Yield()

Loading WASM...

Without Yield()

Loading WASM...
⇧ Top