MCPcopy Create free account
hub / github.com/pulsar-edit/pulsar / constructor

Method constructor

packages/git-diff/lib/git-diff-view.js:13–36  ·  view source on GitHub ↗
(editor, editorElement)

Source from the content-addressed store, hash-verified

11 */
12export default class GitDiffView {
13 constructor(editor, editorElement) {
14 // These are the only members guaranteed to exist.
15 this.subscriptions = new CompositeDisposable();
16 this.editor = editor;
17 this.editorElement = editorElement;
18 this.repository = null;
19 this.markers = new Map();
20
21 // Assign `null` to all possible child vars here so the JS engine doesn't
22 // have to re-evaluate the microcode when we do eventually need them.
23 this.releaseChildren();
24
25 // I know this looks janky but it works. Class methods are available
26 // before the constructor is executed. It's a micro-opt above lambdas.
27 const subscribeToRepository = this.subscribeToRepository.bind(this);
28 // WARNING: This gets handed to requestAnimationFrame, so it must be bound.
29 this.updateDiffs = this.updateDiffs.bind(this);
30
31 subscribeToRepository();
32
33 this.subscriptions.add(
34 atom.project.onDidChangePaths(subscribeToRepository)
35 );
36 }
37
38 /**
39 * @describe Handles tear down of destructables and subscriptions.

Callers

nothing calls this directly

Calls 3

releaseChildrenMethod · 0.95
onDidChangePathsMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected