我在我的 react native 应用程序中使用 redux observable,如果凭据无效,我想在我的登录屏幕上显示一个 react native 警报对话框。我可以在我的史诗中发出警报,但在史诗中我只能返回一个可观察的,那么如何使用 redux observable 来实现这一点?
- 更新01
验证码:
export const signInFailure = (payload) => {
return {
type: SIGN_IN_FAILURE,
payload
}
};
const signInSuccessActions = (payload) => {
return Observable.concat(
Observable.of({type: SIGN_IN_SUCCESS, payload}),
Observable.of({type: 'Navigation/NAVIGATE', routeName: 'MainTabView'})
);
};
export const signInRequestEpic = action$ =>
action$.ofType(SIGN_IN_REQUEST)
.mergeMap(action => AuthService.login(action.email, action.password)
.flatMap(payload => payload.status === 200 ? signInSuccessActions(payload) : signInFailure(payload))
.catch(error => Observable.of({
type: SIGN_IN_FAILURE,
error
}))
);
在 react native 中使用 alert api 只是 1 班轮
import {Alert} from "react-native";
Alert.alert(
'Invalid',
'Email or password incorrect',
)