Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot "apply" #11

Open
rborn opened this issue Feb 6, 2015 · 5 comments
Open

Cannot "apply" #11

rborn opened this issue Feb 6, 2015 · 5 comments

Comments

@rborn
Copy link

rborn commented Feb 6, 2015

Hi David,

I'm trying to use your lib but it seems I'm not managing to :(
I get a runtime error.

The alloy.js

Alloy.Globals.nano = require("nano");
Alloy.Globals.nano.syntax(/\-\=(.+?)\=\-/gi);

the xml:

    <Label id="fname" class="name" text="-=firstname=-" oneway/>
    <Label id="lname" class="name" text="-=lastname=-" oneway/>

The controller:

var userData =  {
     firstname : '',
     lastname : ''
 }

Alloy.Globals.nano($,userData);

setTimeout(function(){
    userData.firstname = 'moo';

    Alloy.Globals.nano.apply();
    console.error(userData);
}, 2000);

the KBoom:


[ERROR] Exception caught during observer callback: file:PATH_TO_MY_APP.app/nano.js:8313:39
[ERROR] callHook@file:PATH_TO_MY_APP.app/nano.js:8280:13
[ERROR] file:PATH_TO_MY_APP.app/nano.js:8312:31
[ERROR] report_@file:PATH_TO_MY_APP.app/nano.js:2973:29
[ERROR] check_@file:PATH_TO_MY_APP.app/nano.js:3240:19
[ERROR] performMicrotaskCheckpoint@file:PATH_TO_MY_APP.app/nano.js:3034:28
[ERROR] apply@file:PATH_TO_MY_APP.app/nano.js:8378:38
[ERROR] file:PATH_TO_MY_APP.app/alloy/controllers/sections/userProfileWindow.js:433:33

[ERROR] { 
[ERROR]     firstname = moo;
[ERROR]     lastname = "";
[ERROR] } 

Any idea what I'm doing wrong?
The above code tries to simulate an xhr call.

If I put the whole nano part and one apply only in the callback it works, bit as soon as I change the model and call again for apply, it crashes.

Thank you :)

@dbankier
Copy link
Owner

dbankier commented Feb 7, 2015

Hi Dan. The example app in the repo also uses a timeout and last time I checked it worked. Will test your code soon.

@rborn
Copy link
Author

rborn commented Feb 7, 2015

Thank you :)

@rborn
Copy link
Author

rborn commented Feb 20, 2015

I think I found the issue:

Removing the commonjs module from tiapp.xml and putting the nano file in /app/lib made the error go away.

Maybe an issue with the module build? or the way Ti treats it?

@dbankier
Copy link
Owner

Hmmm... The compiled files are identical. I wonder what Ti does to mangle it.
Might remove the tiapp.xml way of doing it.
Thanks!

@rotorgames
Copy link

+1 The same thing , only works through Lib.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants