I am trying to hook up my app with in app purchases using this: https://github.com/chirag04/react-native-in-app-utils
I have an epic where I want to emit success if it succeeds, and failure if it fails. Something like this:
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();
}
});
});
};
However I'm not sure how to write the contents of mergeMap
. Is there a way to do this?