Skip to content

[Feature Request] Support Patch-style partial reads in WebSocket get_prop() #3975

Description

@CNFeffery

Is your feature request related to a problem? Please describe.

WebSocket get_prop() already provides a convenient way to read a component property during a callback. It currently returns the complete property value, which works well as a general default.

For large object- or list-shaped props, it could be useful to also support a more flexible partial-read option when only one nested value is needed. For example, a custom button might expose a detailed onClickEvent object, while the callback only needs:

onClickEvent["node1"]["node1-1"]["target"]["value"]

With the current API, the callback retrieves the complete value and then selects this node in Python. An optional client-side path could make this use case more efficient by returning only the requested part.

Describe the solution you'd like

If feasible, it would be helpful for get_prop() to accept an optional partial-read path using the same location types already supported by Dash's Patch: string keys and integer list indices.

For example:

# Nested object value
value = await ws.get_prop(
    "button",
    "onClickEvent",
    path=["node1", "node1-1", "target", "value"],
)

# A list item nested inside an object
record = await ws.get_prop(
    "button",
    "onClickEvent",
    path=["node1", "records", 5],
)

The browser could resolve the path before serialization and return only the selected value or subtree over the WebSocket.

Potential behavior:

  • Support nested combinations of string keys and integer indices, matching Patch location semantics.
  • Keep the current full-property behavior when path is omitted.
  • Preserve the existing asynchronous and timeout behavior.
  • Document the behavior for missing keys or invalid indices.

Describe alternatives you've considered

The existing approach of retrieving the complete prop and selecting the value in Python remains straightforward. A clientside callback and a small dcc.Store can also provide similar behavior. A built-in optional path would offer a more concise approach for this use case.

Additional context

This could complement the existing get_prop() API with a focused read-side counterpart to Patch: optionally retrieve a nested location without returning the complete property.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions