import { DeferValue } from "./deferValue";


/**
 * @author : Aamir khan
 * @description : helper to define idle values/props
 * @param {!Object} obj The object to define the property on.
 * @param {string} prop The property name.
 * @param {!Function} init An initialization function to by run idly.
 */
export const defineDeferProp = (obj, prop, init) => {
  const value = new DeferValue(init);

  Object.defineProperty(obj, prop, {
    configurable: true,
    get: value.getValue.bind(value),
    set: value.setValue.bind(value),
  });
};