How to use the electron-better-ipc.ipcRenderer.on function in electron-better-ipc

To help you get started, we’ve selected a few electron-better-ipc 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 npezza93 / archipelago / app / renderer / sessions / session.js View on Github external
onExit(callback) {
    ipc.on(`pty-exit-${this.id}`, callback)
    return new Disposable(() => {
      ipc.removeListener(`pty-exit-${this.id}`, callback)
    })
  }
github npezza93 / archipelago / app / renderer / about / about.jsx View on Github external
bindListeners() {
    const boundChanger = this.handleDarkModeChange.bind(this)
    ipc.on('dark-mode-changed', boundChanger)
    this.addSubscription(
      new Disposable(() => ipc.removeListener('dark-mode-changed', boundChanger))
    )

    ipc.on('close-via-menu', window.close)
    this.addSubscription(
      new Disposable(() => ipc.removeListener('close-via-menu', window.close))
    )
    ipc.answerMain('close', () => {
      return new Promise(resolve => {
        this.cleanup()
        resolve()
      })
    })
  }
}
github npezza93 / archipelago / app / renderer / search / search.jsx View on Github external
bindListeners() {
    this.addSubscription(new Disposable(ipc.answerMain('search-next', this.searchNext)))
    this.addSubscription(new Disposable(ipc.answerMain('search-previous', this.searchPrevious)))

    const boundChanger = this.handleDarkModeChange.bind(this)
    ipc.on('dark-mode-changed', boundChanger)
    this.addSubscription(
      new Disposable(() => ipc.removeListener('dark-mode-changed', boundChanger))
    )

    ipc.on('close-via-menu', window.close)
    this.addSubscription(
      new Disposable(() => ipc.removeListener('close-via-menu', window.close))
    )
    ipc.answerMain('close', () => {
      return new Promise(resolve => {
        this.cleanup()
        resolve()
      })
    })
  }
}
github npezza93 / archipelago / app / renderer / settings / settings.jsx View on Github external
bindListeners() {
    const boundChanger = this.handleDarkModeChange.bind(this)
    ipc.on('dark-mode-changed', boundChanger)
    this.addSubscription(
      new Disposable(() => ipc.removeListener('dark-mode-changed', boundChanger))
    )

    ipc.on('close-via-menu', window.close)
    this.addSubscription(
      new Disposable(() => ipc.removeListener('close-via-menu', window.close))
    )

    this.addSubscription(new Disposable(
      ipc.answerMain('close', () => {
        return new Promise(resolve => {
          this.cleanup()
          resolve()
        })
      })
    ))
  }
}
github npezza93 / archipelago / app / renderer / search / search.jsx View on Github external
bindListeners() {
    this.addSubscription(new Disposable(ipc.answerMain('search-next', this.searchNext)))
    this.addSubscription(new Disposable(ipc.answerMain('search-previous', this.searchPrevious)))

    const boundChanger = this.handleDarkModeChange.bind(this)
    ipc.on('dark-mode-changed', boundChanger)
    this.addSubscription(
      new Disposable(() => ipc.removeListener('dark-mode-changed', boundChanger))
    )

    ipc.on('close-via-menu', window.close)
    this.addSubscription(
      new Disposable(() => ipc.removeListener('close-via-menu', window.close))
    )
    ipc.answerMain('close', () => {
      return new Promise(resolve => {
        this.cleanup()
        resolve()
      })
    })
  }
}
github npezza93 / archipelago / app / renderer / about / about.jsx View on Github external
bindListeners() {
    const boundChanger = this.handleDarkModeChange.bind(this)
    ipc.on('dark-mode-changed', boundChanger)
    this.addSubscription(
      new Disposable(() => ipc.removeListener('dark-mode-changed', boundChanger))
    )

    ipc.on('close-via-menu', window.close)
    this.addSubscription(
      new Disposable(() => ipc.removeListener('close-via-menu', window.close))
    )
    ipc.answerMain('close', () => {
      return new Promise(resolve => {
        this.cleanup()
        resolve()
      })
    })
  }
}
github npezza93 / archipelago / app / renderer / settings / settings.jsx View on Github external
bindListeners() {
    const boundChanger = this.handleDarkModeChange.bind(this)
    ipc.on('dark-mode-changed', boundChanger)
    this.addSubscription(
      new Disposable(() => ipc.removeListener('dark-mode-changed', boundChanger))
    )

    ipc.on('close-via-menu', window.close)
    this.addSubscription(
      new Disposable(() => ipc.removeListener('close-via-menu', window.close))
    )

    this.addSubscription(new Disposable(
      ipc.answerMain('close', () => {
        return new Promise(resolve => {
          this.cleanup()
          resolve()
        })
      })
github npezza93 / archipelago / app / renderer / sessions / session.js View on Github external
this.webLinksAddon = new WebLinksAddon((event, uri) => {
      if (document.querySelector('webview')) {
        document.querySelector('webview').remove()
      }

      if (platform({macos: event.metaKey, default: event.ctrlKey})) {
        const webview = document.createElement('webview')
        webview.setAttribute('src', uri)
        document.querySelector('body').append(webview)
      }
    })

    this.xterm.loadAddon(this.webLinksAddon)
    this.xterm.attachCustomKeyEventHandler(this.keybindingHandler)

    ipc.on(`pty-data-${this.id}`, this.writePtyData)
    this.subscriptions.add(new Disposable(() => {
      ipc.removeListener(`pty-data-${this.id}`, this.writePtyData)
    }))
    this.subscriptions.add(this.onData(data => {
      ipc.send(`pty-write-${this.id}`, data)
    }))
    this.subscriptions.add(this.onTitle(this.setTitle))
    this.subscriptions.add(this.onFocus(this.fit))
    this.subscriptions.add(this.onFocus(this.resetBlink))
    this.subscriptions.add(this.onSelection(this.copySelection))
    this.subscriptions.add(new Disposable(ipc.answerMain('active-profile-changed', this.onActiveProfileChange)))
    this.subscriptions.add(new Disposable(ipc.answerMain('setting-changed', this.onSettingChanged)))
  }
}
github npezza93 / archipelago / app / renderer / app / app.jsx View on Github external
bindListeners() {
    this.addSubscription(
      new Disposable(() => ipc.removeListener('close-via-menu', this.closeViaMenu))
    )
    ipc.on('close-via-menu', this.closeViaMenu)
    this.addSubscription(new Disposable(ipc.answerMain('split', this.split)))
    this.addSubscription(new Disposable(ipc.answerMain('new-tab', this.addTab)))
    this.addSubscription(new Disposable(ipc.answerMain('search-next', this.searchNext)))
    this.addSubscription(new Disposable(ipc.answerMain('search-previous', this.searchPrevious)))
    this.addSubscription(new Disposable(ipc.answerMain('setting-changed', this.handleSettingChanged)))
    this.addSubscription(new Disposable(ipc.answerMain('active-profile-changed', this.handleActiveProfileChanged)))
    this.addSubscription(new Disposable(ipc.answerMain('close', this.handleClose)))
  }
}