我正在尝试使用以下方法将我的应用与应用内购买挂钩:https ://github.com/chirag04/react-native-in-app-utils
我有一个史诗,如果它成功,我想发出成功,如果失败,我想发出失败。像这样的东西:
import 'rxjs';
import { InAppUtils } from 'NativeModules';
import * as packagesActions from '../ducks/packages';
import * as subscriptionActions from '../ducks/subscription';
export default function createSubscription(action$, store) {
return action$.ofType(packagesActions.SELECT)
.mergeMap(action => {
const productId = action.payload;
InAppUtils.purchaseProduct(productId, (error, response) => {
if(response && response.productIdentifier) {
return subscriptionActions.subscribeSuccess();
} else {
return subscriptionActions.subscribeFailure();
}
});
});
};
但是我不确定如何编写mergeMap
. 有没有办法做到这一点?