Map a primitive value stored in a Firebase ref to a Knockout observable.
Similar to knockoutFire or knockout-sync except instead of starting with observables and bolting on synchronization, ko.firebase
produces observables directly from Firebase
instances. The result is an observables (or observablesArray) that stay in sync with Firebase for both reads and writes.
It extends Firebase instances to add methods to get a knockout observable (for primitive values) or an observableArray of observables (for sets of primitives) from a Firebase location:
var firebase = new Firebase('...');
var foobarObservable = firebase.child('foobar').asObservable();
// or: var foobarObservable = ko.firebase.observable(firebase.child('foobar'));
Which means you can end up with a bidirectionally synchronized textfield with just:
...
<input type="text" data-bind="value: foobar">
...
ko.applyBindings({
foobar: foobarObservable
});
by Erik Beeson; MIT License. Feedback appreciated. Check out my other Firebase projects on github. Find me in #firebase on freenode or firebase-talk@googlegroups.com
Untested, unsupported; use at your own risk.