Mixin: intercept_mixin

intercept_mixin

This mixin installs interceptor function for any existant methods other than get() and set().
Source:

Example

function getWrapper(method, defaults) {
  console.error('wrapping:', method);
  return function() {
    console.error('called:', method, arguments[0]);
    defaults.apply(this, arguments);
  };
}

var MyKago = KagoDB.inherit();
var intercept_mixin = KagoDB.bundle.intercept_mixin;
MyKago.mixin(intercept_mixin(getWrapper)); // => 'wrapping: read' etc.

var opts = {
  storage: 'memory'
};
var collection = new MyKago(opts);
collection.read('foo'); // => 'called: read foo'