caretaker-sdk
TypeScript icon, indicating that this package has built-in type declarations

7.9.4 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i caretaker-sdk

Weekly Downloads

1

Version

7.9.4

License

MIT

Unpacked Size

5.37 MB

Total Files

406

Last publish

Collaborators

  • christiandrey