peerlibrary / meteor-blaze-components

Reusable components for Blaze
http://components.meteorapp.com/
BSD 3-Clause "New" or "Revised" License
354 stars 26 forks source link

mixins causes 'Exception in defer callback' #108

Closed DevTash closed 8 years ago

DevTash commented 8 years ago

It could be me but I have also tried the examples presented at components.meteor.com and the error still occurs.

Composing components is fine, however whenever I implement the mixins method on a component which returns a the mixin list an 'Exception in defer callback' error is thrown. If I remove this mixins method the no error is thrown.

I'm using FlowRouter and Blaze-Layout, unsure whether Blaze-Layout is playing any part into, but for the best part of a day I've been trying to get mixins to work but the error is thrown.

Weirdly, if I requireMixin() no error is thrown but the functionality expected in no exhibited.

mitar commented 8 years ago

Sorry, this is far too little information to be able to help you. Can you show some code? Make a small reproduction app which exhibit your problem? Also, just an exception is not enough, please share the whole stack trace.

DevTash commented 8 years ago

Example app reproducing exception: https://github.com/DevTash/MixinsError

The example app uses your SmartInputComponent example from http://components.meteor.com - Removing all mixins from from the component mixin list, so that the mixins() returns an empty array causes no exception to be thrown.

The stack trace makes reference to BlazeComponent.prototype.createMixins

Stack Trace file Mixin Exception Call Stack.txt

mitar commented 8 years ago

I think the issue is that you moved mixins into other files but you didn't export them to other files. In Meteor, if you do something like var AutoSelectInputMixin = ... this makes AutoSelectInputMixin scoped to the file only. If you want to be available outside of the file, you should remove var at the beginning.

Which browser do you use? Because in Chrome I get a nice stack trace:

Exception in defer callback: ReferenceError: AutoSelectInputMixin is not defined
    at BlazeComponent.extendComponent.mixins (http://127.0.0.1:3000/app/client/components/smartInputComponent.js?94dff1b67c05825b936133f589164dc5e07d4931:16:13)
    at BlazeComponent.createMixins (http://127.0.0.1:3000/packages/peerlibrary_blaze-components.js?015e1eb30b191686996f3bedbd6f966c5b6ef6c1:615:17)
    at http://127.0.0.1:3000/packages/peerlibrary_blaze-components.js?015e1eb30b191686996f3bedbd6f966c5b6ef6c1:749:19
    at Object.Tracker.nonreactive (http://127.0.0.1:3000/packages/tracker.js?7776276660c988c38fed448d8262b925dffb5bc3:615:12)
    at BlazeComponent.renderComponent (http://127.0.0.1:3000/packages/peerlibrary_blaze-components.js?015e1eb30b191686996f3bedbd6f966c5b6ef6c1:745:20)
    at http://127.0.0.1:3000/packages/peerlibrary_blaze-components.js?015e1eb30b191686996f3bedbd6f966c5b6ef6c1:704:30
    at Template._withTemplateInstanceFunc (http://127.0.0.1:3000/packages/blaze.js?9391df93ba5076c2cfc61ee68724eb79b65f00d9:3671:12)
    at http://127.0.0.1:3000/packages/peerlibrary_blaze-components.js?015e1eb30b191686996f3bedbd6f966c5b6ef6c1:701:18
    at Object.Tracker.nonreactive (http://127.0.0.1:3000/packages/tracker.js?7776276660c988c38fed448d8262b925dffb5bc3:615:12)
    at Function.BlazeComponent.renderComponent (http://127.0.0.1:3000/packages/peerlibrary_blaze-components.js?015e1eb30b191686996f3bedbd6f966c5b6ef6c1:690:20)

Which tells me nicely what is wrong: AutoSelectInputMixin is not defined.

Moreover, you will have to add peerlibrary:reactive-field package for things to work completely.

DevTash commented 8 years ago

Ah, that makes sense.

I was using Firefox and just open Chrome to test after I had saw this, the output the Stack Trace in Firefox is no where near as helpful as Chrome. I will note this for future...

Thanks for the help, great package by the way.