Skip to content

Introduce support for composite instance #150

Open

Description

@zxqfd555

Is your feature request related to a problem? Please describe.
Some operators currently allow specifying an instance, for example, in window operators. However, in all tutorials and most examples, the instance is presented as a single field.

In practice, there are cases where it is necessary to define an instance composed of multiple components. This is already technically possible today, but it is not obvious to users how such a composite instance is represented and accessed.

Currently, the instance is available via pw.this._pw_instance, where individual components can be accessed as array elements:

  • index 0 corresponds to the first component,
  • index 1 to the second component,
  • and so on.

This behavior is non-obvious and poorly documented, which makes working with composite instances confusing for users.

Describe the solution you'd like
The solution consists of two parts:

  1. Expose the underlying _pw_instance in a more user-friendly way, so that users can access the instance directly via something like pw.this.instance. A more ergonomic API could be proposed here (suggestions are welcome).
  2. Add a clear example of using composite instances to the tutorials on the website.

Describe alternatives you've considered
Keeping the current behavior as-is.
This is a non-desired alternative, as user feedback indicates that composite instances are a real and recurring need.

Additional context
Since this change only involves making the existing _pw_instance mechanism publicly accessible, no breaking changes are expected. The solution should be fully backward-compatible.

Activity

  1. self-assigned this
    on Dec 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions