pocketbase-react 0.1.8 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,7 @@ import { appReducer } from './reducers';
5
5
  import thunk from 'redux-thunk';
6
6
  import { RecordAction } from './reducers/records';
7
7
  import AsyncStorage from '@react-native-async-storage/async-storage';
8
+ import { StorageService } from '../service/Storage';
8
9
 
9
10
  interface Storage {
10
11
  getItem(key: string, ...args: Array<any>): any;
@@ -14,29 +15,14 @@ interface Storage {
14
15
 
15
16
 
16
17
  const CustomStorage: Storage = {
17
- getItem: async (_key: string, ..._args: Array<any>) => {
18
- if (typeof document !== 'undefined') {
19
- return localStorage.getItem(_key);
20
- }
21
- else if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
22
- return await AsyncStorage.getItem(_key);
23
- }
18
+ getItem: async (key: string, ..._args: Array<any>) => {
19
+ return await StorageService.get(key);
24
20
  },
25
- setItem: async (_key: string, _value: any, ..._args: Array<any>) => {
26
- if (typeof document !== 'undefined') {
27
- return localStorage.setItem(_key, _value);
28
- }
29
- else if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
30
- return await AsyncStorage.setItem(_key, _value);
31
- }
21
+ setItem: async (key: string, value: any, ..._args: Array<any>) => {
22
+ return StorageService.set(key, value);
32
23
  },
33
- removeItem: async (_key: string, ..._args: Array<any>) => {
34
- if (typeof document !== 'undefined') {
35
- return localStorage.removeItem(_key);
36
- }
37
- else if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
38
- return await AsyncStorage.removeItem(_key);
39
- }
24
+ removeItem: async (key: string, ..._args: Array<any>) => {
25
+ return StorageService.remove(key);
40
26
  },
41
27
  };
42
28