At FeldsparTech we are working on a no-code platform called Atman. Atman's UI is a component library that works as a standalone application or can be embedded into another application to enable quick no-code workflows.

One of our goals is to allow granular control over our components. If this only meant rendering - we would build Renderless components. However, we also want the consuming application to be able to override, modify and augment behavior.

The approach we have chosen to achieve this goal is to use a Vuex store.

if(!this.$store.hasModule("ourlibrary")){
   this.$store.registerModule("ourlibrary", store);
}

Overriding behavior example

 overriddenMethod({dispatch},params){
    if(this._actions["overriddenMethod"]) {
       return dispatch("overriddenMethod", params, {root:true});
    } else {
      //Default behavior
    }
}

Augmenting behavior example

 augmentedMethod({dispatch},params){
     let response;
     /*
        Internal logic which updates `response`
        ...
     */
    if(this._actions["augmentedMethod"]) {
       globalResponse = dispatch("augmentedMethod", params, {root:true});
    }
    /*
        Update `response` with `globalResponse`
    */
    return response;
}

This pattern is quite powerful. For instance, you can now even allow the consuming application to entirely replace a particular nested component with one of its own.

Here, the vuex action functions as a Factory. Now you can customize the logic as per your needs. The Overriding approach will entirely replace default component. The Augmentation approach will allow the consuming application to add business-specific components you may not want in the library.