perform in-place delta updates of extension API ExtWindow and ExtCodeEditor
Created by: sqs
This allows holders of references to these objects to actually listen for changes, instead of having the objects wiped away.
For example, take CodeEditor#selectionsChanges
. Right now, this is defined as public readonly selectionsChanges = of(this._selections)
, so it only emits once. You can construct an RxJS pipe to make this work as intended (to listen for selections changes), but there are 2 limitations:
- If you have
const editor = activeWindow.activeViewComponent
, theneditor.selectionsChanges
will get stale when the selection actually changes. You need to use RxJS pipes, which is unintuitive. Authors assume theeditor
object will be updated in-place. - If there is a more expensive observable, such as
editor.visibleRangesChanges
(which would rely on a DOM MutationObserver), then you don't want to resubscribe every time any small change is made to the editor (like its content changes).
This addresses those issues without any regressions to existing behavior and makes the extension API work slightly more in line with the author's expectations.