brendanjerwin / accessorizejs Goto Github PK
View Code? Open in Web Editor NEWAdd observable accessors to any object.
Home Page: www.accessorizejs.com
Add observable accessors to any object.
Home Page: www.accessorizejs.com
I need to support all three...
var parent = accessorize({child:undefined});
parent.child({value:"hello"});
parent.child().value("world");
alert(parent.child().value()); //"world"
The second time its called it should simply short-circuit and return.
Need a few different forms for release:
So a client can subscribe to all changed properties in one place.
AOP style?
Add the ability to provide custom logic for the setter/getters of accessors.
This is how a computed property can be implemented.
Read Only seems like the most obvious. But all three modes should be made available: Read/Write, Read Only, Write Only.
Should this only be available for adjustment at the original accessorization?
On either the wrapped object or individual accessor level, add ability to pause updates for performance reasons. Continue should only fire the change event once for each changed accessor/wrapper.
Perhaps a throttle approach would work as well/better?
If the accessor has a non-null and non-undefined value.
Should add validators to a list on the accessorized object.
Bound to one or more properties, will execute when any of the bound values are being set. Can prevent a set from happening. No change notification will occur if the set is aborted.
Needs to deal with validation of the entire model and with validation of a single property.
we need 'em
Like ko has on its observables:
"To write values to multiple observable properties on a model object, you can use chaining syntax. For example, myViewModel.personName('Mary').personAge(50)
will change the name value to 'Mary' and the age value to 50."
Arrays don't make sense as a wrapped object.
It makes sense, this is intended to run in a browser... I'll use jasmine-node or something to get the nice dev-time experience back.
See: https://developer.mozilla.org/en/json
This will provide a JSON representation that ignores the accessors and provides the underlying property values.
If underscore is available, when an accessor is created, create an
underscore wrapper for the backing value and then mix in its methods
directly on the accessor.
Perhaps a black-list will be needed...
If the item being accessorized is an Array, Number, or String then we should return an accessor function.
A better API surface would be to simply call accessorize(obj)
.
And have it actually call subscribers on change.
So a new property can be added to the wrapped object after the initial accessorization.
Will be useful to deal with setting an existing Array property value to a numerical value.
Maybe the new es5 property stuff can help. At least in supported browsers.
If the value of a property is an array at the time it is accessorized, lots of cool magic happens.
What about when the value of a property is changed to/from an array after accessorization?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.