smartxworks/sunmao-ui

The way to extends a Trait.

Opened this issue · 1 comments

What problem does this feature solve?
Sometimes traits need to be extended. For example, Validation Trait presets some rules, but the business logic always requires custom validation rules. Validation Trait needs to receive and register custom rules.

What does the proposed API look like?
Since the trait is a factory function, so one of the ways may be injecting dependencies in the trait's constructor function. And trait's dependencies can be passed in initSunmao(not the dependencies filed, but a new field).

How about

  1. Pass the extended things as props if they are serializable.
  2. Implement a new trait.