Skip to content

[Feature] Add support for sibling configuration #697

@titouanmathis

Description

@titouanmathis

We can configure children component with the components config property:

import { Base } from '@studiometa/js-toolkit';
import { Bar } from './Bar.js';

class Foo extends Base {
  static config = {
    name: 'Foo',
    components: { 
      Bar,
    },
  }
}

It might be interesting to be able to configure siblings: components that would be mounted on the same element. This would allow for more composable features, as this would help get around the limitations of class inheritance (extending only one class, method or property names conflicts, etc.).

For example, a component which would need Transition capabilities could declare the Transition component as a sibling instead of extending from it.

Before

class Foo extends Transition {
  static config = {
    name: 'Foo',
  };

  onClick() {
    this.enter();
  }
}

After

class Foo extends Base {
  static config = {
    name: 'Foo',
    use: { // or `with`?
      Transition,
    }
  };

  onClick() {
    this.$siblings.Transition.enter();
  }
}

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