Hi All,
I've created a new JS library for defining properties that can be subscribed for updates and can interact with eachother.
Check it here;
Readme contains many examples. Here is another one:
var user = ak47({ name: 'joe', 'birthdate': 21 });
> user.name()
"joe"
> user.name.subscribe(console.log);
> user.name("mike")
"mike"
"mike" "joe"
Defining a new property that observes another(s):
> var greeting = ak47(joe.name, function(name){
return 'Hello ' + name;
});
> greeting()
"Hello mike"
> joe.name("joe")
> greeting()
"Hello joe"
What do you think?
Azer
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
Implementation is still in progress. CLs that were landed introduce
the skeleton of the system but there are no notifications coming in
from the runtime yet.
I don't know what the actual plan is but I would expect that
implementation would degrade only performance of the observed objects
not the system as whole like prototype did (similar to Object.freeze).
--
Vyacheslav Egorov
It was non-optimized. After reading your response, I spent couple of
hours on optimizing it. Here are the numbers:
You mean that benchmark doesn't contain any accessor or ak47 misses accessors?
Here is how I define a property with getters and setters using ak47:
function getter(d){ return Number(d); }
function setter(d){ return new Date(d); }
var date = a.property(new Date('1.1.1990'), getter, setter);
And that benchmark case uses default accessors unlike the example above.
On Tue, Oct 30, 2012 at 11:36 AM, Rick Waldron <waldro...@gmail.com> wrote:That's why ak47 exists! It introduces a new way of defining
>
> A little misleading, because what you're illustrating is actually just "a
> function". JavaScript accessors are created by defining get/set property
> descriptors or named get/set accessors.
properties. I don't think prefixing accessors as get/set is essential
to fill the definition of "accessor" in a dynamic language.