Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
computed-observable
Advanced tools
#computed observable
npm install computed-observable
An approximate implementation of Knockout's computed observables.
##Usage
var CO = require('computed-observable');
A somewhat familiar interface
Note that you don't have to invoke this.firstName
or this.lastName
within the computed
function. Just reference the variables naturally. The same goes for assignment. Notice that we use person.firstName =
instead of invoking some setter function.
function Person() {
this.observable('firstName', 'Bobby');
this.observable('lastName', 'Stevenson');
this.computed('fullName', function() {
return this.firstName + ' ' + this.lastName;
});
};
var person = new CO(Person);
person.on('changed', function() {
console.log('Model changed', this.fullName);
});
person.firstName = 'Stanislaw';
An unfamiliar interface
You can give CO
an initialization function, or an object containing properties.
var person = new CO({
firstName: 'Bobby',
lastName: 'Stevenson',
fullName: function() {
return this.firstName + ' ' + this.lastName;
}
});
person.on('changed', function() {
//this.fullName === 'Stanislaw Stevenson'
});
person.firstName = 'Stanislaw';
Here, it's assumed that function
properties are meant to be dynamic (computed), while other attributes are meant to be observable. This reduces boilerplate significantly.
##License
MIT
FAQs
An approximate impementation of computed observables
The npm package computed-observable receives a total of 1 weekly downloads. As such, computed-observable popularity was classified as not popular.
We found that computed-observable demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.