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

can.compute error with can.Observe #436

Merged
merged 1 commit into from
Jul 18, 2013
Merged

can.compute error with can.Observe #436

merged 1 commit into from
Jul 18, 2013

Conversation

daffl
Copy link
Contributor

@daffl daffl commented Jul 17, 2013

https://github.com/bitovi/canjs/blob/master/observe/compute/compute.js#L338

if( can.Observe.__reading && canReadForChangeEvent) {
    can.Observe.__reading(computed,'change');
}

This conditional assumes can.Observe exists. Just need an extra if(can.Observe && can.Observe.__reading...

Noting this until I get back to it(unless someone beats me to this!)

@khoinguyen
Copy link

I also got the same problem, especially when use with AMD RequireJS, and optimised by r.js

$ r.js -o build.js 

Tracing dependencies for: main

/Project/www/scripts/main-built.js
----------------
/Project/www/scripts/less.js
/Project/www/scripts/sockjs-0.3.4.min.js
/Project/www/scripts/jquery-1.8.2.min.js
/Project/www/scripts/jquery.ba-hashchange-1.3.js
/Project/www/scripts/vertxbus.js
/Project/www/scripts/can/util/can.js
/Project/www/scripts/can/util/array/each.js
/Project/www/scripts/can/util/jquery.js
/Project/www/scripts/can/util/library.js
/Project/www/scripts/can/view.js
/Project/www/scripts/can/util/string.js
/Project/www/scripts/can/util/bind.js
/Project/www/scripts/can/observe/compute.js <<< Note here, No can/observe was included
/Project/www/scripts/can/view/elements.js
/Project/www/scripts/can/view/scanner.js
/Project/www/scripts/can/view/node_lists.js
/Project/www/scripts/can/view/live.js
/Project/www/scripts/can/view/render.js
/Project/www/scripts/can/view/ejs.js
/Project/www/scripts/can/construct.js
/Project/www/scripts/can/control.js
/Project/www/scripts/domReady.js
domReady!
/Project/www/scripts/app/widget/ChatWidget.js
/Project/www/scripts/app/main.js
/Project/www/scripts/main.js

Result: Uncaught TypeError: Cannot read property '__reading' of undefined

I fixed this issue in can/observe/compute.js:

define(["can/util/library", "can/util/bind"], function(can, bind) {

change to

define(["can/util/library", "can/util/bind", "can/observe"], function(can, bind) {

Output of r.js

$r.js -o build.js 

Tracing dependencies for: main

/Project/www/scripts/main-built.js
----------------
/Project/www/scripts/less.js
/Project/www/scripts/sockjs-0.3.4.min.js
/Project/www/scripts/jquery-1.8.2.min.js
/Project/www/scripts/jquery.ba-hashchange-1.3.js
/Project/www/scripts/vertxbus.js
/Project/www/scripts/can/util/can.js
/Project/www/scripts/can/util/array/each.js
/Project/www/scripts/can/util/jquery.js
/Project/www/scripts/can/util/library.js
/Project/www/scripts/can/view.js
/Project/www/scripts/can/util/string.js
/Project/www/scripts/can/util/bind.js
/Project/www/scripts/can/construct.js
/Project/www/scripts/can/observe.js <<< Note here, can/observe.js was included in the optimised file
/Project/www/scripts/can/observe/compute.js
/Project/www/scripts/can/view/elements.js
/Project/www/scripts/can/view/scanner.js
/Project/www/scripts/can/view/node_lists.js
/Project/www/scripts/can/view/live.js
/Project/www/scripts/can/view/render.js
/Project/www/scripts/can/view/ejs.js
/Project/www/scripts/can/control.js
/Project/www/scripts/domReady.js
domReady!
/Project/www/scripts/app/widget/ChatWidget.js
/Project/www/scripts/app/main.js
/Project/www/scripts/main.js

daffl added a commit that referenced this pull request Jul 18, 2013
can.compute error with can.Observe
@daffl daffl merged commit 5469f73 into master Jul 18, 2013
@daffl daffl deleted the compute-error-436 branch July 18, 2013 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants