-
Notifications
You must be signed in to change notification settings - Fork 268
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
Is it possilble to have Lazy.events (Event sequences) for value change? #49
Comments
Hey, thanks for the kind words! I like that idea. It should definitely be possible with Maybe something like |
Dan Tao, As I mentioned earlier, what I found very smart is your design of lazy.js is the first and only one which properly integrate Lazy evaluation functional library and Async/Reactive programming.
which is I considered the name of the Lazy generate method, but can't decide, basically I trust your naming sense. |
UPDATE: need to share this I found some library Object.prototype.watch() (Mozilla/Gekko/Firefox Only) eligrey / object-watch.js (Confirmed to work in the latest Firefox/Chrome) I think |
UPDATE2: found a better one |
Here's what I've got so far: var object = {},
values = Lazy(object).watch('foo'),
truthyValues = values.compact();
var auditLog = [];
truthyValues.each(function(value) {
auditLog.push(value);
});
object.foo = 100;
object.foo = null;
object.foo = true;
object.foo = 'bar';
object.foo = false;
auditLog.toArray(); // => [100, true, 'bar'] Make sense? |
Slghtly. Does this behave in the same manner of, say, |
You're right that This first commit was just a simple PoC. I can also implement the option to watch multiple properties, or all properties, like: // Watch multiple properties
Lazy(object).watch(['foo', 'bar']).each(callback);
// Watch all (existing) properties
Lazy(object).watch().each(callback); I could also look into watching for new properties, like Watch.JS does; but that library uses As for the multiple/all properties functionality, though, I'll add that in an upcoming commit. |
Dan, Sounds great.
None of libraries including Watch.js works for Arrays properly so far, and yes, Once, I considered polling to Array/new properties, but I end up with closure so that I can bind jsObject and behavior. Of course, this manner itself is not Functional/Declarative programming style (no Referential transparency), but to make mathematical model separated from IO, we do need this.
Please keep up the great work. |
Dan, I tried Lazy(obj).watch for my own project. So far, I use watch.js, and with that, the code works as it should be, so it must be the lazy().watch probelm. Ken |
Dan, thanks for the update for this issue. Just let you know things I had not known when I opened this topic. ECMAScript 6 seems to have http://wiki.ecmascript.org/doku.php?id=harmony:observe#object.observe I have informed you Now, I personally use some implementation to work on the current ES5. |
Thanks for bringing that up! As it turns out, I did read about |
Well, it looks like I'm going to close this issue as |
lazy.js is one of the best project I've ever found.
This library integrates undersocre/linq.js and RxJS with lazy evaluation advantage where I feel that a clean and complete implementation of Functional/Declarative programming paradigm is deployed; All the JS programmers should learn from this.
Thank you, Dan Tao.
Having said that, I have a question:
Basically, I want to bind javascript value with DOM element behavior.
To monitor
myval
change event, I could code something like:Is it possilble to have Lazy.events like this??
The text was updated successfully, but these errors were encountered: