File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -65,7 +65,10 @@ class IPC {
6565 ipc . server . emit ( client , 'message' , message ) ;
6666 }
6767
68- listenTo ( action , callback ) {
68+ listenTo ( action , callback = ( ) => { } ) {
69+ if ( ! this . connected ) {
70+ return callback ( ) ;
71+ }
6972 ipc . of [ 'embark' ] . on ( action , ( messageString ) => {
7073 callback ( parse ( messageString ) ) ;
7174 } ) ;
@@ -75,7 +78,10 @@ class IPC {
7578 ipc . server . broadcast ( action , stringify ( data ) ) ;
7679 }
7780
78- once ( action , cb ) {
81+ once ( action , cb = ( ) => { } ) {
82+ if ( ! this . connected ) {
83+ return cb ( ) ;
84+ }
7985 ipc . of [ 'embark' ] . once ( 'message' , function ( messageString ) {
8086 const message = parse ( messageString ) ;
8187 if ( message . action !== action ) {
@@ -86,6 +92,10 @@ class IPC {
8692 }
8793
8894 request ( action , data , cb ) {
95+ if ( ! this . connected ) {
96+ cb = cb || ( ( ) => { } ) ;
97+ return cb ( ) ;
98+ }
8999 if ( cb ) {
90100 this . once ( action , cb ) ;
91101 }
You can’t perform that action at this time.
0 commit comments