How to use etch - 10 common examples

To help you get started, we’ve selected a few etch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github maisk / atom-psql / lib / variables-view.js View on Github external
destroy() {
    // console.log('DESTROY variables', this.now);
    this.liveFlag = false;
    etch.destroy(this);
    this.disposables.dispose();
  }
github atom / keybinding-resolver / spec / keybinding-resolver-view-spec.js View on Github external
}
      })

      atom.commands.dispatch(workspaceElement, 'key-binding-resolver:toggle')

      // Not partial because it dispatches the command for `x` immediately due to only having keyup events in remainder of partial match
      document.dispatchEvent(atom.keymaps.constructor.buildKeydownEvent('x', {target: workspaceElement}))
      await etch.getScheduler().getNextUpdatePromise()
      expect(workspaceElement.querySelector('.key-binding-resolver .keystroke').textContent).toBe('x')
      expect(workspaceElement.querySelectorAll('.key-binding-resolver .used')).toHaveLength(1)
      expect(workspaceElement.querySelectorAll('.key-binding-resolver .unused')).toHaveLength(0)
      expect(workspaceElement.querySelectorAll('.key-binding-resolver .unmatched')).toHaveLength(1)

      // It should not render the keyup event data because there is no match
      document.dispatchEvent(atom.keymaps.constructor.buildKeyupEvent('x', {target: workspaceElement}))
      await etch.getScheduler().getNextUpdatePromise()
      expect(workspaceElement.querySelector('.key-binding-resolver .keystroke').textContent).toBe('x ^x')
      expect(workspaceElement.querySelectorAll('.key-binding-resolver .used')).toHaveLength(1)
      expect(workspaceElement.querySelectorAll('.key-binding-resolver .unused')).toHaveLength(0)
      expect(workspaceElement.querySelectorAll('.key-binding-resolver .unmatched')).toHaveLength(0)

      document.dispatchEvent(atom.keymaps.constructor.buildKeydownEvent('a', {target: workspaceElement}))
      await etch.getScheduler().getNextUpdatePromise()
      expect(workspaceElement.querySelector('.key-binding-resolver .keystroke').textContent).toBe('a (partial)')
      expect(workspaceElement.querySelectorAll('.key-binding-resolver .used')).toHaveLength(0)
      expect(workspaceElement.querySelectorAll('.key-binding-resolver .unused')).toHaveLength(1)
      expect(workspaceElement.querySelectorAll('.key-binding-resolver .unmatched')).toHaveLength(0)

      document.dispatchEvent(atom.keymaps.constructor.buildKeyupEvent('a', {target: workspaceElement}))
      await etch.getScheduler().getNextUpdatePromise()
      expect(workspaceElement.querySelector('.key-binding-resolver .keystroke').textContent).toBe('a ^a')
      expect(workspaceElement.querySelectorAll('.key-binding-resolver .used')).toHaveLength(1)
github atom / keybinding-resolver / spec / keybinding-resolver-view-spec.js View on Github external
'.never-again': {
          'x': 'unmatch-2'
        }
      })

      atom.commands.dispatch(workspaceElement, 'key-binding-resolver:toggle')

      document.dispatchEvent(atom.keymaps.constructor.buildKeydownEvent('x', {target: workspaceElement}))
      await etch.getScheduler().getNextUpdatePromise()
      expect(workspaceElement.querySelector('.key-binding-resolver .keystroke').textContent).toBe('x')
      expect(workspaceElement.querySelectorAll('.key-binding-resolver .used')).toHaveLength(1)
      expect(workspaceElement.querySelectorAll('.key-binding-resolver .unused')).toHaveLength(1)
      expect(workspaceElement.querySelectorAll('.key-binding-resolver .unmatched')).toHaveLength(1)

      // It should not render the keyup event data because there is no match
      spyOn(etch.getScheduler(), 'updateDocument').andCallThrough()
      document.dispatchEvent(atom.keymaps.constructor.buildKeyupEvent('x', {target: workspaceElement}))
      expect(etch.getScheduler().updateDocument).not.toHaveBeenCalled()
      expect(workspaceElement.querySelector('.key-binding-resolver .keystroke').textContent).toBe('x')
      expect(workspaceElement.querySelectorAll('.key-binding-resolver .used')).toHaveLength(1)
      expect(workspaceElement.querySelectorAll('.key-binding-resolver .unused')).toHaveLength(1)
      expect(workspaceElement.querySelectorAll('.key-binding-resolver .unmatched')).toHaveLength(1)
    })
github atom / atom / src / dock.js View on Github external
elementAttached() {
    // Re-render when the dock is attached to make sure we remeasure sizes defined in CSS.
    etch.updateSync(this);
  }
github jsmecham / atom-terminal-tab / lib / terminal-view.js View on Github external
this.disposables = new CompositeDisposable();
    this.session = session;

    // Load the Fit Addon
    this.fitAddon = new FitAddon();
    this.session.xterm.loadAddon(this.fitAddon);
    this.disposables.add(this.fitAddon);

    //
    // Observe the Session to know when it is destroyed so that we can
    // clean up our state (i.e. remove event observers).
    //
    this.session.onDidDestroy(this.destroy.bind(this));

    // TODO: Documentation says this should be set for Atom... Research!
    etch.setScheduler(atom.views);
    etch.initialize(this);

    this.observeResizeEvents();
  }
github TypeStrong / atom-typescript / dist / main / atomts.js View on Github external
async function activate(state) {
    const pns = atom.packages.getAvailablePackageNames();
    const packagesProvidingUIServices = ["atom-ide-ui", "linter", "nuclide"];
    if (!packagesProvidingUIServices.some(p => pns.includes(p))) {
        // tslint:disable-next-line:no-unsafe-any
        await require("atom-package-deps").install("atom-typescript", true);
    }
    // tslint:disable-next-line:no-unsafe-any
    require("etch").setScheduler(atom.views);
    // tslint:disable-next-line:no-shadowed-variable
    const { PluginManager } = require("./pluginManager");
    pluginManager = new PluginManager(state);
}
exports.activate = activate;
github appcelerator / atom-appcelerator-titanium / lib / ui / newProjectDialog.jsx View on Github external
submit() {
		if (!this.state.submitButtonEnabled) {
			return;
		}
		this.state.executing = true;
		this.opts.callback && this.opts.callback(this.project);
		etch.update(this);
	}
github ioquatix / script-runner / lib / script-runner-view.js View on Github external
constructor(uri, title) {
		Etch.initialize(this);
		console.log("element", this.element);
		
		this.uri = uri;
		
		this.emitter = new Emitter;
		
		atom.commands.add(this.element, {
			'script-runner:copy': () => this.copyToClipboard(),
			'script-runner:paste': () => this.pasteToTerminal(),
			'script-runner:clear': () => this.clear(),
			'script-runner:interrupt': event => this.kill('SIGINT'),
			'script-runner:terminate': event => this.kill('SIGTERM'),
			'script-runner:kill': event => this.kill('SIGKILL'),
		});
		
		if (title == null)
github atom / github / lib / git / commit-box / commit-box-component.js View on Github external
acceptProps ({viewModel}: CommitBoxComponentProps): Promise {
    this.viewModel = viewModel

    let updatePromise = Promise.resolve()
    if (this.element) {
      updatePromise = etch.update(this)
    } else {
      etch.initialize(this)
      this.listener = new DOMListener(this.element)
    }

    if (this.subscriptions) this.subscriptions.dispose()
    this.subscriptions = new CompositeDisposable()
    this.subscriptions.add(this.listener.add('.git-CommitBox-button', 'click', () => this.commit()))

    this.subscriptions.add(atom.commands.add(this.element, {
      'git:commit': () => this.commit()
    }))

    this.subscriptions.add(atom.commands.add('atom-workspace', {
      'git:focus-commit-message': () => this.focus(),
      'git:focus-commit-button': () => this.focusCommitButton()
    }))
github wonderunit / storyboarder / src / js / window / scene-timeline-view.js View on Github external
async update (props, children) {
    if (props.scale != null) this.scale = props.scale
    if (props.kind != null) this.kind = props.kind
    if (props.mini != null) this.mini = props.mini
    this.children = children

    await etch.update(this)

    this.forceChildrenUpdate()
  }

etch

Perform virtual DOM updates based on changes to a data model.

MIT
Latest version published 4 years ago

Package Health Score

51 / 100
Full package analysis