我可以将此代码更改为RxJava编码样式吗?当前的实现如下。我想更改代码以从Async调用获取数据,并将其用于UpdatePublisherImpl.java文件中的其他内容。
基本上,从TokenUpdateService.updateBIToken()获得的任何结果都想用于进一步处理。
无论如何,我可以将此代码更改为RxJava编码样式,并将ABCResponse返回给另一种方法进行进一步处理吗?
//Requires here
function findOrCreate(key, cb) {
db.collection('users').findOne(key, (err, user) => {
if (err) {
console.error(err);
} else {
if (!user) {
db.collection("users").insert(key, cb)
} else {
cb(err, user);
}
db.close();
}
});
}
// config
passport.use(new FacebookStrategy(
{
clientID: config.facebook.clientID,
clientSecret: config.facebook.clientSecret,
callbackURL: config.facebook.callbackURL
},
function(accessToken, refreshToken, profile, done) {
findOrCreate({
auth: "facebook",
id: profile.id
}, function (err, user) {
return done(err, user);
});
}
));
var app = express();
//View engine setup here
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({
extended: false
}));
app.use(cookieParser('sekret'));
app.use(express.static(path.join(__dirname, 'public')));
//Routes here
const cookieExpirationDate = new Date();
const cookieExpirationDays = 365;
cookieExpirationDate.setDate(cookieExpirationDate.getDate() + cookieExpirationDays);
app.use(session({
secret: 'sekret',
saveUninitialized: true,
resave: true
}));
app.use(passport.initialize());
app.use(passport.session());
app.get('/auth/facebook', passport.authenticate('facebook'));
app.get('/auth/facebook/callback',
passport.authenticate('facebook', {
successRedirect: '/my-reptiles',
failureRedirect: '/'
})
);
app.get('/logout', function(req, res){
req.logout();
res.redirect('/');
});
//Error handling here
module.exports = app;