stampit: Can't override normal function with generator function with `methods`
I changed the hook definition from #223 and implemented is a noop function:
let DefaultHooks = stampit().methods({
preHook:() => {}
});
so I can override it with an implementation if needed in other stamps like:
let LoggerHooks = stampit().compose(DefaultHooks).methods({
preHook:function *() {
yield console.log(arg);
}
});
This works only for normal functions and not for generator functions. My current workarround is
let LoggerHooks = stampit().compose(DefaultHooks).init(function ({instance}) {
instance.preHook = function *() {
yield console.log(arg);
};
});
@koresar I took a short try with current v3rc but it breaks my code base too hard. Perhaps this is already fixed in v3?
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 18 (13 by maintainers)
Lodash v4 does consider generators as functions, so it’s merely problem of v3, so it’s not necessary to report that.
I’ve merged pull request, lodash does too sofisticated checks for our needs.
Okay, so stampit is using
lodash/isFunctionto check values. Lodash is not usingtypeof value === 'function'. Instead, it is usingvalue.toString() === '[object Function]'.I believe stampit v2 need a fix to allow generators, as well as stampit v3. Right?
To fix stampit v2 we need to patch the
supermixermodule. Any volunteers?I’ll fix stampit v3.
v3 is stable. Not released though. 😃 Working on it as we speak.