# Callback III

As a final, practical example of callbacks, consider the following.

```python
import pyblish.api
from maya import cmds

def on_instance_toggled(instance, new_value, old_value):
  node = instance.data["nodeName"]
  cmds.setAttr(node + ".publish", new_value)
```

Assuming that the publishable state of your instance in Maya is determined by the user-defined attribute "publish", this callback will cause the GUI to persist the toggled state of any given instance directly in your scene.

Now, both when you reset Pyblish, reload your scene or even save the file and restart Maya, the state at which it was visually toggled will persist.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.pyblish.com/22-callback-iii.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
