From 391b9cd0f918683e9b26f45c8962bb2d7f54053c Mon Sep 17 00:00:00 2001 From: HNgocL Date: Mon, 10 May 2021 14:08:28 +0700 Subject: [PATCH] config type saga, fix flipper ios --- package.json | 2 +- template/ios/Podfile | 2 +- .../unAuthentication/login/saga/saga.ts | 3 +- template/src/app/library/networking/saga.ts | 36 ++++++++++++++----- 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index c4f68a51..fd0e0182 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rn-boiler-template", - "version": "1.64.10", + "version": "1.64.11", "description": "Clean and minimalist React Native template for a quick start with TypeScript and components", "scripts": { "test": "exit 0" diff --git a/template/ios/Podfile b/template/ios/Podfile index ad4ef78d..41f67c49 100644 --- a/template/ios/Podfile +++ b/template/ios/Podfile @@ -21,7 +21,7 @@ target 'HelloWorld' do # # Note that if you have use_frameworks! enabled, Flipper will not work and # you should disable the next line. - use_flipper!() + use_flipper!({ 'Flipper-Folly' => '2.5.3', 'Flipper' => '0.87.0', 'Flipper-RSocket' => '1.3.1' }) post_install do |installer| react_native_post_install(installer) diff --git a/template/src/app/features/unAuthentication/login/saga/saga.ts b/template/src/app/features/unAuthentication/login/saga/saga.ts index 02af73b0..3ddca6c5 100644 --- a/template/src/app/features/unAuthentication/login/saga/saga.ts +++ b/template/src/app/features/unAuthentication/login/saga/saga.ts @@ -1,3 +1,4 @@ +import {ResponseBase} from '@config/type'; import {ServiceSaga} from '@networking'; import {Action} from 'redux'; import {call, put} from 'redux-saga/effects'; @@ -9,7 +10,7 @@ export function* onLogin(action: Action) { if (actions.onLogin.match(action)) { const {body, onFailure, onSucceeded, url} = action.payload; yield put(actions.onStart()); - const response = yield ServiceSaga.Post(url, body); + const response: ResponseBase = yield ServiceSaga.Post(url, body); if (response) { if (response.data) { if (onCheckType(onSucceeded, 'function')) { diff --git a/template/src/app/library/networking/saga.ts b/template/src/app/library/networking/saga.ts index 3212563b..5b4ddbd7 100644 --- a/template/src/app/library/networking/saga.ts +++ b/template/src/app/library/networking/saga.ts @@ -1,4 +1,5 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ +import {ResponseBase} from '@config/type'; import {StyleSheet} from 'react-native'; import {TIME_OUT, RESULT_CODE_PUSH_OUT} from '@config/api'; import {AppState} from '@app_redux/type'; @@ -12,7 +13,7 @@ import {ApiConstants} from './api'; import {handleResponseAxios, handleErrorAxios, _onPushLogout} from './helper'; const tokenKeyHeader = 'authorization'; -let refreshTokenRequest: Promise | null = null; +let refreshTokenRequest: Promise | null = null; const AxiosInstance = Axios.create({}); AxiosInstance.interceptors.response.use( @@ -50,7 +51,10 @@ async function refreshToken(originalRequest: any) { } // base -function* Request(config: AxiosRequestConfig, isCheckOut = true) { +function* Request( + config: AxiosRequestConfig, + isCheckOut = true, +): Generator, any> { const {token, appUrl}: AppState = yield select((x: any) => x.app); const defaultConfig: AxiosRequestConfig = { baseURL: appUrl, @@ -63,7 +67,7 @@ function* Request(config: AxiosRequestConfig, isCheckOut = true) { return yield AxiosInstance.request( StyleSheet.flatten([defaultConfig, config]), ) - .then((res: any) => { + .then((res: AxiosResponse) => { const result = handleResponseAxios(res); return result; }) @@ -81,29 +85,45 @@ function* Request(config: AxiosRequestConfig, isCheckOut = true) { }); } // get -function* Get(url: string, param?: any) { +function* Get( + url: string, + param?: any, +): Generator, any> { return yield Request({url: url, params: param, method: 'GET'}); } // post -function* Post(url: string, data: any) { +function* Post( + url: string, + data: any, +): Generator, any> { return yield Request({url: url, data: data, method: 'POST'}); } // post file -function* PostWithFile(url: string, data: any) { +function* PostWithFile( + url: string, + data: any, +): Generator, any> { const {token}: AppState = yield select((x: RootState) => x.app); const header: any = {token: token, 'Content-Type': 'multipart/form-data'}; return yield Request({url: url, data: data, method: 'POST', headers: header}); } // put -function* Put(url: string, data: any, params?: any) { +function* Put( + url: string, + data: any, + params?: any, +): Generator, any> { return yield Request({url: url, data: data, params: params, method: 'PUT'}); } // delete -function* Delete(url: string, params?: any) { +function* Delete( + url: string, + params?: any, +): Generator, any> { return yield Request({ url: url, params: params,