Get started with universal-mixin CDN

MIT licensed

JS utility: Universal-Mixin ensures client-server rendering consistency.

Tags:
  • mixins
  • traits
  • ES3
  • ES5
  • ES6
  • ES2015
  • ES.future
  • ES.next

Stable version

Copied!

How to start using universal-mixin CDN


// Include the UniversalMixin library
const UniversalMixin = require('universal-mixin/dist/universal-mixin.min.js')(window);

// Define a base component
class BaseComponent {
  constructor() {
    this.init();
  }

  init() {
    console.log('Base component initialized.');
  }
}

// Define a derived component using UniversalMixin
class DerivedComponent extends BaseComponent {
  constructor() {
    super();

    // Use UniversalMixin to extend the derived component
    UniversalMixin(this, {
      init() {
        console.log('Derived component initialized.');
      },

      render() {
        console.log('Rendering derived component.');
      }
    });
  }

  render() {
    // Implement the render method
    console.log('Rendering derived component with custom implementation.');
  }
}

// Instantiate and initialize the derived component
const derivedComponent = new DerivedComponent();
Copied!
Copied!
Copied!
Copied!

All versions