It doesn’t log anything for me (even though PS is in dev mode), so maybe Adobe removed this experimental feature.
You’re better of using event listeners, since they can be used in production, unlike app.eventNotifier.
If you want to capture all events, you could do
but you should rather only listen to the events you really need for your logic.
So let’s say you’d want to run some code whenever the user selects the layer called “Test Layer 1”,
you’d need to listen to the select event first of all. All the relevant information (or “instructions”) of the select event are stored in the descriptor, so you can use it to make further checks.
const onSelect = (_, descriptor) => {
if(descriptor._target?.[0]._ref === "layer" && descriptor._target?.[0]._name === "Test Layer 1") {
// -> The layer with name "Test Layer 1" was selected
}
}
require("photoshop").action.addNotificationListener(['select'], onSelect);
If that descriptor._target?.[0]?. is confusing: If the event ran successfully, the reference to the target (receiving that action/event) is stored in _target. However, if something goes wrong that property might not be there, so it’s safer to use optional chaining to prevent any runtime errors.
That I don’t have to use one listener for all needed events and switch/case inside, but rather assign different functions for different events. I think this will make code more readable and maintainable