I am not sure what the callback function should look like if I want to do this. Both functions are in a class and I really want to abstract it.
doesexist: function(setvalue) {
redisclient.sismember('setname', setvaue, callbackfuntion(value));
}
someothermethod: function() {
if (doesexist()){
// doSomething
}
}
How would I do that in an async environment?
UPDATE:
I now tried it that way (coffeescript):
deoesexist: (setvalue, cb) ->
@r.sismember 'setname', setvalue, (err, res) -> cb(res)
someothermethod: (setvalue) ->
@doesexist setvalue, (exists) =>
unless exists
# emit an event that calls a function
# that probably adds the not existing value.
# I just don't want to redo this. That's
# what this function is all about
It seems to work pretty well like that.