Comments (7)
I've modified the sample code to include yours but couldn't get any error. Here it is:
http://plnkr.co/edit/pyaadTBIzBwxdfVQa3s2?p=preview
And here's the test code:
ko.watch(vm.name, { depth: -1 }, function (parents, child, item) {
alert(child());
}, this);
from knockoutjs-reactor.
The only difference I see is that I tried to setup ko.watch from code INSIDE the vm itself. Can be this the problem?
from knockoutjs-reactor.
@Trapulo Ok I've set up ko.watch "inside the vm" here:
http://plnkr.co/edit/g9YvhLKHzDjE8WQGFbe5?p=preview
Am I missing anything else? Not sure I got you right.
from knockoutjs-reactor.
your
// Log changes in the view model.
ko.watch(vm, {...
is outside of
var vm = {...
Basically I tried to have a watcher activated inside the vm (in "constructor", or in an event handler).
However, because my project is quite complex and also I'm using typescript as js source, I've implemented a more fine and custom tuned solution using koLite as sample. I'll try again to insert your library when I will need the undo feature.
Thanks for your assistance.
from knockoutjs-reactor.
Glad you found your way out. So that explains the term "TypeError" in your error message. That might be because ko.watch uses optional and dynamically typed arguments which is confusing the TypeScript compiler.
The workaround then is to define an interface for ko.watch that takes in all the parameter types separately like overrides in static languages. That's just my 2 cents though. I haven't had a chance to try TypeScript myself but I'm looking forward to it.
You're welcome.
from knockoutjs-reactor.
Sorry for late reply.
Strange, because the compiler didn't report any error.
However I will notify result of future tests. Thanks for your assistance, I appreciate it.
from knockoutjs-reactor.
Ok I'm looking forward to that. It would be great if you could reproduce the error by modifying the sample code I sent you earlier.
But now that I'm reconsidering your issue I'm realizing that this error is thrown when calling an object like a function(with parentheses) but it isn't a function. So it might have nothing to do with TypeScript in itself. In your case it means options
is somehow being called like a function but I have no idea how. If the error message is not helping you locate it then you might consider setting up a few break points and stepping through the code until the error occurs. Also make sure your target object is fully generated when you're setting up the watcher because altering the target structure later on can confuse it. You can always try setting the mutable
option to true to get around it but it only works when the changes occur within an observable. You might also try setting hideWrappedValues
to true so as to prevent child()
from being called just in case it's not a function as assumed inside my code where it is called.
from knockoutjs-reactor.
Related Issues (20)
- disposal does not work when mutable and not oldValues
- Multiple watch break on dispose HOT 2
- Bower Accessible HOT 12
- Cannot ignore observable arrays HOT 3
- AMD module support HOT 2
- How can we reset it? HOT 1
- Not Compatible with knockout 3.4 HOT 3
- Uncaught Subscriptions field (.G) not defined for observable child HOT 3
- Issue with KO 3.3.0 and the minified reactor HOT 1
- "un-watch" functionality... HOT 1
- New release? HOT 3
- Uncaught Subscriptions field (.K) not defined for observable child Error only when using knockout.debug HOT 9
- npm ko-reactor version is stuck at 1.3.7 HOT 7
- Not working corrrectly with KO 3.4.2
- Keep notifying changes for replaced objects
- Bad parents in the notifications when sub-objects are replaced
- Basic functional test suite HOT 1
- How use a ko-reactor with require() and webpack?
- Missing "main" declaration in package.json HOT 1
- KO Reactor / KO Undo Manager compatibility (context is not a function) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from knockoutjs-reactor.