Skip to content

Commit

Permalink
feat: Add onFirstInstanceAck event for requestSingleInstanceLock
Browse files Browse the repository at this point in the history
  • Loading branch information
rzhao271 committed Oct 22, 2021
1 parent 1d0f94f commit c2218f0
Show file tree
Hide file tree
Showing 5 changed files with 373 additions and 55 deletions.
19 changes: 19 additions & 0 deletions docs/api/app.md
Expand Up @@ -484,6 +484,7 @@ Returns:
* `argv` String[] - An array of the second instance's command line arguments
* `workingDirectory` String - The second instance's working directory
* `additionalData` unknown - A JSON object of additional data passed from the second instance
* `ackCallback` unknown - A function that can be used to send data back to the second instance

This event will be emitted inside the primary instance of your application
when a second instance has been executed and calls `app.requestSingleInstanceLock()`.
Expand All @@ -495,12 +496,30 @@ non-minimized.

**Note:** If the second instance is started by a different user than the first, the `argv` array will not include the arguments.

**Note:** `ackCallback` allows the user to send data back to the
second instance during the `app.requestSingleInstanceLock()` flow.
This callback can be used for cases where the second instance
needs to obtain additional information from the first instance
before quitting.
In order to call the callback, `event.preventDefault()` must be called
Then, the `ackCallback` callback can be called.
If the callback is not called in either case, `null` will be sent back.

This event is guaranteed to be emitted after the `ready` event of `app`
gets emitted.

**Note:** Extra command line arguments might be added by Chromium,
such as `--original-process-start-time`.

### Event: 'first-instance-ack'

Returns:

* `event` Event
* `additionalData` unknown - A JSON object of additional data passed from the first instance, in response to the first instance's `second-instance` event.

This event will be emitted within the second instance during the call to `app.requestSingleInstanceLock()`, when the first instance calls the `ackCallback` provided by the `second-instance` event handler.

## Methods

The `app` object has the following methods:
Expand Down
2 changes: 1 addition & 1 deletion patches/chromium/.patches
Expand Up @@ -106,6 +106,6 @@ feat_expose_raw_response_headers_from_urlloader.patch
chore_do_not_use_chrome_windows_in_cryptotoken_webrequestsender.patch
process_singleton.patch
fix_expose_decrementcapturercount_in_web_contents_impl.patch
feat_add_data_parameter_to_processsingleton.patch
mas_gate_private_enterprise_APIs
load_v8_snapshot_in_browser_process.patch
feat_add_data_transfer_to_requestsingleinstancelock.patch

0 comments on commit c2218f0

Please sign in to comment.