Skip to content

New feature - composers

Compare
Choose a tag to compare
@koresar koresar released this 11 Oct 09:44
· 14 commits to master since this release

More information can be found here.

Composers are designed to mutate the resulting stamp to your needs.

Example:

import stampit from 'stampit';

const SelfAware = stampit()
  .composers(({stamp, composables}) => {
    const methods = stamp.compose.methods || {};
    methods.getStamp = () => stamp; // mutation! Adding a method
    stamp.compose.methods = methods;
  });

const MyOtherStamp = stampit( ... ).compose(SelfAware); // add the behavior
const obj = MyOtherStamp();
MyOtherStamp === obj.getStamp();