How to use the etch.getScheduler function in etch

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 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 lexicalunit / atom-notes / lib / select-list-view.js View on Github external
renderItems () {
    if (this.items.length > 0) {
      const className = ['list-group'].concat(this.props.itemsClassList || []).join(' ')

      if (this.visibilityObserver) {
        etch.getScheduler().updateDocument(() => {
          Array.from(this.refs.items.children).slice(this.props.initiallyVisibleItemCount).forEach(element => {
            this.visibilityObserver.observe(element)
          })
        })
      }

      this.listItems = this.items.map((item, index) => {
        const selected = this.getSelectedItem() === item
        const visible = !this.props.initiallyVisibleItemCount || index < this.props.initiallyVisibleItemCount
        return $(ListItemView, {
          element: this.props.elementForItem(item, { selected, index, visible }),
          selected: selected,
          onclick: () => this.didClickItem(index)
        })
      })
github lexicalunit / atom-notes / lib / select-list-view.js View on Github external
this.element.removeEventListener('mousedown', this.mouseDown)
    this.element.removeEventListener('mouseup', this.mouseUp)
    this.element.removeEventListener('click', this.didClick)

    this.element.parentNode.replaceChild(props.element, this.element)
    this.element = props.element
    this.element.addEventListener('mousedown', this.mouseDown)
    this.element.addEventListener('mouseup', this.mouseUp)
    this.element.addEventListener('click', this.didClick)
    if (props.selected) {
      this.element.classList.add('selected')
    }

    this.selected = props.selected
    this.onclick = props.onclick
    etch.getScheduler().updateDocument(this.scrollIntoViewIfNeeded.bind(this))
  }
github atom / atom-select-list / src / select-list-view.js View on Github external
this.element.removeEventListener('mousedown', this.mouseDown)
    this.element.removeEventListener('mouseup', this.mouseUp)
    this.element.removeEventListener('click', this.didClick)

    this.element.parentNode.replaceChild(props.element, this.element)
    this.element = props.element
    this.element.addEventListener('mousedown', this.mouseDown)
    this.element.addEventListener('mouseup', this.mouseUp)
    this.element.addEventListener('click', this.didClick)
    if (props.selected) {
      this.element.classList.add('selected')
    }

    this.selected = props.selected
    this.onclick = props.onclick
    etch.getScheduler().updateDocument(this.scrollIntoViewIfNeeded.bind(this))
  }
github atom / atom / spec / workspace-element-spec.js View on Github external
const getNextUpdatePromise = () => etch.getScheduler().nextUpdatePromise;
github atom / atom / src / text-editor-component.js View on Github external
scheduleUpdate (nextUpdateOnlyBlinksCursors = false) {
    if (!this.visible) return

    this.nextUpdateOnlyBlinksCursors =
      this.nextUpdateOnlyBlinksCursors !== false && nextUpdateOnlyBlinksCursors === true

    if (this.updatedSynchronously) {
      this.updateSync()
    } else if (!this.updateScheduled) {
      this.updateScheduled = true
      etch.getScheduler().updateDocument(() => {
        if (this.updateScheduled) this.updateSync(true)
      })
    }
  }
github atom / atom-select-list / src / select-list-view.js View on Github external
renderItems () {
    if (this.items.length > 0) {
      const className = ['list-group'].concat(this.props.itemsClassList || []).join(' ')

      if (this.visibilityObserver) {
        etch.getScheduler().updateDocument(() => {
          Array.from(this.refs.items.children).slice(this.props.initiallyVisibleItemCount).forEach(element => {
            this.visibilityObserver.observe(element)
          })
        })
      }

      this.listItems = this.items.map((item, index) => {
        const selected = this.getSelectedItem() === item
        const visible = !this.props.initiallyVisibleItemCount || index < this.props.initiallyVisibleItemCount
        return $(ListItemView, {
          element: this.props.elementForItem(item, {selected, index, visible}),
          selected: selected,
          onclick: () => this.didClickItem(index)
        })
      })
github atom / atom-select-list / src / select-list-view.js View on Github external
this.didClick = this.didClick.bind(this)
    this.selected = props.selected
    this.onclick = props.onclick
    this.element = props.element
    this.element.addEventListener('mousedown', this.mouseDown)
    this.element.addEventListener('mouseup', this.mouseUp)
    this.element.addEventListener('click', this.didClick)
    if (this.selected) {
      this.element.classList.add('selected')
    }
    this.domEventsDisposable = new Disposable(() => {
      this.element.removeEventListener('mousedown', this.mouseDown)
      this.element.removeEventListener('mouseup', this.mouseUp)
      this.element.removeEventListener('click', this.didClick)
    })
    etch.getScheduler().updateDocument(this.scrollIntoViewIfNeeded.bind(this))
  }
github atom / about / lib / etch-component.js View on Github external
static getScheduler () {
    return etch.getScheduler()
  }

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