This seems like a straightforward implementation:
ko.observableArray.fn.findEl = function(id) {
return ko.computed(function() {
var ary = this();
return _.any(ary, function(user) { return user.id() === id;});
}, this);
};
But when I call it like:
user.current.following.findEl(valueAccessor())
It returns a function, requiring me to call findEl like:
user.current.following.findEl(valueAccessor())()
which is needless to say, not ideal.
Right, you’re returning the actual computed observable function, which I’m sure you’re aware. As it stands I’d suggest calling the value accessor of the computed observable you’re returning inside your findEl function and just return that value. That at least keeps it inside your one function and you don’t have to worry about having to call the function with the ()() every time.