meteor-famous-views
meteor-famous-views copied to clipboard
TypeError: Illegal constructor
This error appears just on cordova as soon as the app starts. Sometimes nothing renders or stuff renders incorrectly. I tried running the famous-views demo site using cordova on an android device and the same error popped up:
I20141211-17:02:19.830(-3) (android:http://meteor.local/packages/meteor.js:907) Exception from Tracker afterFlush function: Illegal constructor
I20141211-17:02:19.830(-3)? TypeError: Illegal constructor
I20141211-17:02:19.830(-3)? at [object Object].<anonymous> (http://meteor.local/packages/gadicohen_famous-views.js?05cca9d035a48e8d6423fce7acf2769a90af85fd:1394:28)
I20141211-17:02:19.831(-3)? at http://meteor.local/packages/blaze.js?77c0809654ee3a10dcd5a4f961fb1437e7957d33:1720:14
I20141211-17:02:19.831(-3)? at Object.Blaze._withCurrentView (http://meteor.local/packages/blaze.js?77c0809654ee3a10dcd5a4f961fb1437e7957d33:2029:12)
I20141211-17:02:19.831(-3)? at http://meteor.local/packages/blaze.js?77c0809654ee3a10dcd5a4f961fb1437e7957d33:1719:15
I20141211-17:02:19.831(-3)? at Tracker.flush (http://meteor.local/packages/tracker.js?192a05cc46b867dadbe8bf90dd961f6f8fd1574f:438:11)
At first I thought it was an issue with famous-views > 0.1.26 (as it didn't appear back then), but then I downgraded and the error was still there. The only thing that I changed in between was updating Meteor from 1.0.0 to 1.0.1. But I'm not sure this is the origin of the problem though, because the error appeared on the famous-views demo site running Meteor 1.0.0.
EDIT: My problem is now fixed. Apparently it didn't have anything to do with the error message displayed above. The message still persists, but it's not causing any apparent damage.
Hi @Wenape, The main site isn't foreseen to run in app mode. This could explain the strange behavior. How did you set the famousContext
?
BTW, I've set up a special repo for reproducing error on mobile: https://github.com/PEM--/repro It could help you in your journey in the hybrid dev.
I think I found the origin of the problem, it has to do with explicitly setting a famousContext. Up to famous-views 0.1.26 I wasn't explicitly setting any famousContext and everything worked correctly. Updated to 0.1.29 and had to set a context for everything to continue to work correctly (issue #188):
<template name="layout">
{{#famousContext id="mainCtx" size='[undefined, undefined]'}}
{{> yield}}
{{/famousContext}}
</template>
But now that I'm using a famousContext, cordova won't work anymore. The app works perfectly on browsers though.
Like you can see in the repro. I'm taking a full famo.us approach. For the moment, so far so good. Maybe a dumb a question, do you really need to create an 'in-between' approach with classic HTML mixed with famo.us?
Everything is working now. I used your approach from the repro of using a RenderController at the top level of the app and everything works ok now. No need for a famousContext.
:+1:
Hey, glad you're up and running. Just a quite note though, that even though our aim is to maintain backwards compatibility (to avoid surprises for people upgrading, and for a graceful deprecation warning in the future), using a main famousContext as per the site/docs is our recommended pattern moving forward. You don't "have to" use it but "should" use it, moving forward :)
If you found a case where the site works WITHOUT a famousContext, and breaks WITH, I'd love a repro to take a look at and make sure we get this fixed :)
The recommended pattern is actually the best solution. It doesn't bring up any errors and works correctly. For cordova specifically, not always. What it seems to happen is that the mobile portion of iron-router does not work 100% when using a hybrid approach (like using a famousContext). But for most cases, using a famousContext is the best option.
Ok great to hear! Thanks! P.S. There has been some work currently in 0.1.30-rc.3
that would ensure famousContext works in some potentially weird situations (basically, if a template container famousContext (e.g. body, layout) is rendered before famous-views is ready, we handle this case now).
Nice I'll try it out. I've always had a problem installing other versions of packages. I've tried installing from atmosphere meteor add gadicohen:[email protected]
but it doesn't work. Or do you have to install it using a tarball?
No straight from atmosphere. What error do you get? Assuming you just did a typo now but in case it was a copy and paste, note it's .30-rc
in the middle :>
$ meteor add gadicohen:[email protected]
added coffeescript at version 1.0.4
added pierreeric:cssc at version 1.0.4
added jag:pince at version 0.0.5
added gadicohen:famous-views at version 0.1.30-rc.3
gadicohen:famous-views: Blaze Views for Famous; doing Famous Meteor-style
It was a typo after all, 0.1.30 is working perfectly. I noticed the best approach for cordova is to use a RenderController at the top level of the app as @PEM-- pointed out, and use a defined size:
Template.layout.helpers({
mainLayoutSize: function () {
if (Meteor.isCordova) {
return [window.innerWidth, window.innerHeight];
} else {
return [undefined, undefined];
}
}
});
Cordova doesn't seem to work correctly with a viewport size of undefined
.
We should put something in the doc about it. While debugging an app for a french company that uses famo.us (the project is about to be announced... I can't tell :smile: ), we found that Android requires its sizes to be set for working correctly with forms.
For that, I use an excellent package named gadicohen:reactive-window. The name of the package author reminds me of somebody... can't tell either :wink:
haha :) it's actually a pity, i was thinking about it, we should really just be able to rely on the size of the context, made reactive if necessary like with @mcbain's approach. on my way out now but if you want to add this to the FAQ when you get a chance would be great :)
probably a bug in famo.us though, should work out the box i think?
For me, it is a bug. And famo.us knows it. After 2 hours pair-programming and creating Modifier with animation based on the viewport size to circumvent these bad inputs placements, my friend remembers that there was something in the FAQ of the famous-angular docs...
I have faced the same issue as Wenape, could not run the app on my android device. Only after what I have followed above, reluctantly i remove the famousContext and it worked. Not sure what is the problem here but the error log looks like this:
I20150220-02:22:22.243(7) (android:http://meteor.local/packages/jag_pince.js:158) error: [famous-views]
I20150220-02:22:22.290(7) (android:http://meteor.local/packages/meteor.js:913) Exception from Tracker afterFlush function: Illegal constructor
I20150220-02:22:22.291(7)? TypeError: Illegal constructor
I20150220-02:22:22.292(7)? at [object Object].<anonymous> (http://meteor.local/packages/gadicohen_famous-views.js?fd41b1f3a8f00a0dade5ad3140167aabf83e536d:1469:28)
I20150220-02:22:22.292(7)? at http://meteor.local/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:1733:14
I20150220-02:22:22.293(7)? at Object._withCurrentView (http://meteor.local/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:2043:12)
I20150220-02:22:22.293(7)? at http://meteor.local/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:1732:15
I20150220-02:22:22.293(7)? at http://meteor.local/packages/tracker.js?517c8fe8ed6408951a30941e64a5383a7174bcfa:448:11
Same problem as @minheq. I tried to deploy my application on android device with meteor run android-device and I get this error. My application is just simple test app with code frome https://famous-views.meteor.com examples.