caretaker-sdk
v7.9.4
Published
> SDK for FE apps
Downloads
15
Readme
caretaker-sdk
SDK for FE apps
Install
yarn add caretaker-sdk@latest
Usage
Required setup
At the very root of your project, initialize as shown below;
import {initStrings, initVault, initAnalytics} from 'caretaker-sdk';
import LocalizedStrings from 'react-native-localization'; // <- Or any other localization module
initStrings((data) => new LocalizedStrings(data));
initVault({
getRawAsync: async () => undefined,
getAsync: async () => undefined,
setAsync: async () => false,
hasAsync: async () => false,
removeAsync: async () => false,
removeAllAsync: async () => false,
extraKeys: {},
});
initAnalytics({
setUserId: async () => undefined,
setUserProperty: async () => undefined,
setAnalyticsCollectionEnabled: async () => undefined,
logEvent: async () => undefined,
logScreenView: async () => undefined,
logAppOpen: async () => undefined,
logLogin: async () => undefined,
logSignUp: async () => undefined,
});
Getting shared config file
import {getConfig} from 'caretaker-sdk';
const environmentVariables = {};
const extraConfig = {
cacheTimeout: 150,
};
const config = getConfig(environmentVariables, extraConfig);
Creating app data store
import {createAppStore, Provider, PersistGate} from 'caretaker-sdk';
import {additionalReducer} from './additional-reducer';
import storage from '@react-native-async-storage/async-storage'; // <- Or any other storage module
const {store, persistor} = createAppStore({
devTools: process.env.NODE_ENV !== 'production',
reducers: {
additionalReducer,
},
storage,
});
const App = () => (
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<YourApp />
</PersistGate>
</Provider>
);
License
MIT © christiandrey