How do we iterate over an ObservableUndoableList?

Searching ObservableUndoableList in the jlab codebase leads to the implementation at jupyterlab/undoablelist.ts at b4db7f03d2ad0b91a9c8c252c56ae5e4a9408fbb · jupyterlab/jupyterlab · GitHub, which leads to exploring the parent class ObservableList in jupyterlab/observablelist.ts at b4db7f03d2ad0b91a9c8c252c56ae5e4a9408fbb · jupyterlab/jupyterlab · GitHub. That shows that the class has an iter method, which produced a Lumino iterator and allows the Lumino iteration functionality to be used: see algorithm/src | @lumino.

For example, each iterates over each item.

I think it would be good to add a [Symbol.iterator] field to the observable list class to allow natural js iteration too, for simplicity.

1 Like