Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
backbone-signal
Advanced tools
A rich Signal & Slots (Reactive Programming) api on Backbone Models. It is composable, allows you to encapsulate loader logic, and have fine grained control over listening to change events.
// backbone-signal extends Backbone.Model
var app = new Backbone.Model();
// The block is called with load when the value of the signal is null.
var userSignal = app.signal("user").setLoader(function() {
userSignal.set({
name: "..."
});
});
console.info("Let's see some friends");
// userSignal.value() is null so the loader is called
userSignal.load().getTruthy(app, function(app, user) {
console.info("Hello " + user.name);
});
userSignal.set({
name: "Jane"
});
// userSignal.value() is not null so the loader is not called
userSignal.load().getTruthy(app, function(app, user) {
console.info("Nice to see you");
});
userSignal.set({
name: "Joe"
});
userSignal.unset();
The console ouput is:
Let's see some friends
Hello ...
Hello Jane
Nice to see you
Hello Joe
Nice to see you
First, notice setLoader. The loader is called when load() if first called because userSignal.value() == null (== undefined as well). The second time load() is called, the loader is not called, since userSignal.value() is not == null.
We are calling getTruthy on the userSignal two times, one for "Hello " + user.name and one for "Nice to see you". The callback is invoked when the value is Truthy. So when userSignal.unset is called, the callbacks are not invoked.
What is nice about having a dedicated signal object is that you can bind to it even when it's value is undefined, thereby avoiding order dependencies and simplyfying your logic.
backbone-signal also utilizes Backbone's listenTo and listenToOnce methods, which make it easy to clean up by calling stopListening on the listener.
backbone-signal is being used in www.rundavoo.com and has been fun to use, especially with node.js & Browserify. It's been a pleasure using a lightweight unframework to freely structure the dataflow logic of the site.
#API
http://briantakita.com/articles/backbone-signal-practical-reactive-programming-in-javascript/
FAQs
A rich Signal & Slots api using Backbone.
We found that backbone-signal 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
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.