new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Electron · API · all subjects

notification/events

10 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Notification 'show' event

The 'show' event is emitted when the notification is shown to the user. This event can be fired multiple times as a notification can be shown multiple times through the show() method. The event listener receives an event parameter.

Notification 'click' event

The 'click' event is emitted when the notification is clicked by the user. The event listener receives an event parameter.

Notification 'close' event

The 'close' event is emitted when the notification is closed by manual intervention from the user. This event is not guaranteed to be emitted in all cases where the notification is closed. On Windows, the close event can be emitted in one of three ways: programmatic dismissal with notification.close(), by the user closing the notification, or via system timeout. If a notification is in the Action Center after the initial close event is emitted, a call to notification.close() will remove the notification from the action center but the close event will not be emitted again. The event listener receives a details object with an optional reason property (Windows only) that can be 'userCanceled', 'applicationHidden', or 'timedOut'.

Notification 'reply' event macOS Windows

The 'reply' event is emitted on macOS and Windows when the user clicks the 'Reply' button on a notification with hasReply: true. The event listener receives a details object with a reply property containing the string the user entered into the inline reply field. There is also a deprecated reply parameter passed as a second argument.

Notification 'action' event macOS Windows

The 'action' event is emitted on macOS and Windows when an action is triggered on the notification. The event listener receives a details object with actionIndex (number, the index of the action that was activated) and selectionIndex (number, Windows only, the index of the selected item or -1 if none was chosen). There are also deprecated actionIndex and selectionIndex parameters passed as additional arguments.

Notification 'failed' event macOS Windows

The 'failed' event is emitted on macOS and Windows when an error is encountered while creating and showing the native notification. The event listener receives an event parameter and an error string parameter describing the error encountered during execution of the show() method.

Notification click event example

const { Notification, app } = require('electron') app.whenReady().then(() => { const n = new Notification({ title: 'Title!', subtitle: 'Subtitle!', body: 'Body!' }) n.on('click', () => console.log('Notification clicked!')) n.show() }) This example shows how to create a notification and listen for the click event.

Notification close event example

const { Notification, app } = require('electron') app.whenReady().then(() => { const n = new Notification({ title: 'Title!', subtitle: 'Subtitle!', body: 'Body!' }) n.on('close', () => console.log('Notification closed!')) n.show() }) This example shows how to create a notification and listen for the close event.

Notification reply event example

const { Notification, app } = require('electron') app.whenReady().then(() => { const n = new Notification({ title: 'Send a Message', body: 'Body Text', hasReply: true, replyPlaceholder: 'Message text...' }) n.on('reply', (e, reply) => console.log(`User replied: ${reply}`)) n.on('click', () => console.log('Notification clicked')) n.show() }) This example shows how to create a notification with reply functionality and listen for the reply and click events.

Notification failed event example

const { Notification, app } = require('electron') app.whenReady().then(() => { const n = new Notification({ title: 'Bad Action' }) n.on('failed', (e, err) => { console.log('Notification failed: ', err) }) n.show() }) This example shows how to create a notification and listen for the failed event.

Give your agent this brain