Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Fixed the process not quitting.
Browse files Browse the repository at this point in the history
  • Loading branch information
winneon committed May 16, 2017
1 parent 40bbdfb commit 405b4d8
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class App {
register(listener, obj){
let listen = !obj ? this.app : obj

listen.removeAllListeners(listener.name)
//listen.removeAllListeners(listener.name)

listen.on(listener.name, (...args) => {
listener.onEvent(this, args)
Expand Down
15 changes: 15 additions & 0 deletions app/listeners/before-quit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict'

import Listener from '../listener'

class BeforeQuit extends Listener {
constructor(){
super('before-quit')
}

onEvent(app){
app.window.mainWindow.close()
}
}

export default BeforeQuit
15 changes: 15 additions & 0 deletions app/listeners/will-quit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict'

import Listener from '../listener'

class WillQuit extends Listener {
constructor(){
super('will-quit')
}

onEvent(app){
app.exit(0)
}
}

export default WillQuit
4 changes: 4 additions & 0 deletions app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@

import App from './app'
import Ready from './listeners/ready'
import BeforeQuit from './listeners/before-quit'
import WillQuit from './listeners/will-quit'
import WindowAllClosed from './listeners/window-all-closed'

class Main {
constructor(){
this.app = new App()

this.app.register(new Ready())
this.app.register(new BeforeQuit())
this.app.register(new WillQuit())
this.app.register(new WindowAllClosed())
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "A desktop front-end for Spansh's neutron router.",
"author": "Jesse Bryan <[email protected]>",
"productName": "Neutron",
"version": "0.2.1",
"version": "0.2.2",
"main": "index.js",
"dependencies": {
"babel-preset-es2015": "^6.24.1",
Expand Down
3 changes: 2 additions & 1 deletion app/window.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

import { BrowserWindow } from 'electron'
import { BrowserWindow, app } from 'electron'
import path from 'path'

class Window {
Expand Down Expand Up @@ -29,6 +29,7 @@ class Window {

this.mainWindow.on('focus', () => this.mainWindow.webContents.send('focus', true))
this.mainWindow.on('blur', () => this.mainWindow.webContents.send('focus', false))
this.mainWindow.on('close', () => app.quit())

if (process.env.NODE_ENV === 'development'){
this.mainWindow.webContents.openDevTools({
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "neutron",
"description": "A desktop front-end for Spansh's neutron router.",
"author": "Jesse Bryan <[email protected]>",
"version": "0.2.1",
"version": "0.2.2",
"build": {
"asar": false
},
Expand Down

0 comments on commit 405b4d8

Please sign in to comment.