What is the recommended way to import PAUSE in redux-persist? - redux-persist

I am using redux-persist.
One way to pause is using:
persistor.pause();
I hope to pause in my epic. What is the recommended way to import PAUSE?
import { PAUSE } from 'redux-persist/lib/constants';
import { PAUSE } from 'redux-persist/es/constants';
import { PAUSE } from 'redux-persist/src/constants';

I got response from the redux-persist's owner Zack Story.
Right now you can use either of these three.
import { PAUSE } from 'redux-persist/lib/constants';
import { PAUSE } from 'redux-persist/es/constants';
import { PAUSE } from 'redux-persist/src/constants';
In the future, it will be
import { PAUSE } from 'redux-persist';
Please check here for the update.

Related

DeviceInfo.getMacAddress() Causes Production Crash in React Native

I need to get the MAC addresses of our devices to register them on our API. DeviceInfo.getMacAddress() works perfectly when deployed on emulators/devices directly from VS Code. When deployed from the APK file, it crashes with no error/warning. Have even tried wrapping it in a try/catch so I could report out the warning with no results with the same result; code below runs if deployed from VSCode and crashes with no message/alert if built into an APK.
Looked up permissions in React, and don't see anything required to get MAC addresses. What am I doing wrong here?
import React, {useRef, useEffect, useState} from 'react';
import { Text, View, Alert, ActivityIndicator } from 'react-native';
import MainComponent from '../../components/Main';
import ExceptionHandlerComponent from '../../components/common/ExceptionHandler';
import DeviceInfo from 'react-native-device-info';
import { loadScanner } from '../../helpers/scannerService';
import { GetUser } from '../../helpers/userRepo';
import {LogError} from '../../helpers/errorService'
import { LoginScanner } from '../../helpers/scannerService';
import { GenerateNewLog, LogAppSegment }from '../../helpers/correlationLogService'
import { set } from 'react-native-reanimated';
const Main = () => {
useEffect(() => {
try {
DeviceInfo.getMacAddress().then((mac)=>{
Alert.alert(
"Mac below",
mac );
}); }
catch (ex)
{
Alert.alert(
"Error below",
ex.message );
}
},
[]);

How to find device type in expo react-native

I found it a little time-consuming to figure out which device was using my app, as the documentation doesn't have many clear examples and other posts are lacking as well.
You can find that getDeviceTypeAsync() should get the device type but not how to read the result.
Here is a simple solution put together from a few pieces of public code:
import React, { useEffect } from "react";
import { StyleSheet, Text, View } from "react-native";
import { DeviceType, getDeviceTypeAsync } from "expo-device";
export default function DevelopmentScreen() {
const deviceTypeMap = {
[DeviceType.UNKNOWN]: "unknown",
[DeviceType.PHONE]: "phone",
[DeviceType.TABLET]: "tablet",
[DeviceType.DESKTOP]: "desktop",
[DeviceType.TV]: "tv",
};
useEffect(() => {
getDeviceTypeAsync().then((deviceType) => {
console.log(deviceTypeMap[deviceType]);
});
}, []);
return null
}
Cheers!

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle in react native

I can't figured out this warning . I examined import and exports but still I can't comprehend what warning means
Require cycle: src\components\index.ts -> src\components\LoadNavigation.tsx -> src\components\index.ts
//index.ts
export { default as LoadAssets } from "./LoadAssets";
export { default as Loading } from "./Loading";
export { default as LoadNavigation } from './LoadNavigation';
export { default as SafeAreaView } from "./SafeAreaView";
export { SocialIcon, SocialIconButton, SocialIcons } from "./SocialAuth";
//LoadNavigation.tsx
import { AuthenticationNavigator } from "../navigation/auth-navigation";
import { useTypedSelector } from "../redux";
import { Onboarding } from "../screens";
import { AppRoutes } from "../types/navigation-type";
import Loading from "./Loading";
import { useIsFirstLaunch } from "./../hooks/useIsFirstLaunch";
How can I fix this warning. Thanks for any help.

RXJS operators are not functions

I am getting this error when I try to use rxjs in vue using vue-rx with rxjs.
[Vue warn]: Error in created hook: "TypeError: messageObservable.fromEvent(...).map(...).debounceTime is not a function"
I do not see any wrong imports from the documentation that I looked at and I am not getting any build errors when building the JS on my dev enviroment.
THese are the imports that I have
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/fromEvent';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/distinctUntilChanged';
This is the fucntions calling these mehtods.
const messageObservable = Observable;
subscriptions(){
message$: messageObservable
},
created(){
message$.
fromEvent(document.querySelector('textarea'), 'input').
map(event => event.target.value).
debounceTime(500).
distinctUntilChanged().
subscribe({
next: function(value) {
console.log(value);
}
});
},
It seems that the tutorial you are following along is out to date. This imports are not longer working. (see changelog)
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/fromEvent';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/distinctUntilChanged';
The latest and stable version is rxjs6. This is the correct way of using it:
import { fromEvent, map, debounceTime, distinctUntilChanged, switchMap } from 'rxjs/operators'
import { Observable } from 'rxjs';
...
created() {
message$.
pipe(
map(event => event.target.value),
debounceTime(500),
distinctUntilChanged()
).subscribe(console.log);
}
I am guessing this is how you want to use fromEvent.
created() {
message$.
pipe(
switchMap(val => fromEvent(document.querySelector('textarea'), 'input'))
map(event => event.target.value),
debounceTime(500),
distinctUntilChanged()
).subscribe(console.log);
}

Cannot find module 'timers'

i use method setTimeout in my users.component.ts but does not work and get
cannot find module 'timers' error
i import this code but does not work
import { setTimeout } from 'timers'
I have used SetInterval function, Also remove the import statement that is autogenerated.
Ex :
import { Component, OnInit } from '#angular/core';
//import { setInterval } from 'timers';
export class HelloWorldComponent implements OnInit {
message : string ;
constructor() {
setInterval(() => {
let currentDate = new Date();
this.message = currentDate.toDateString() + " " + currentDate.toLocaleTimeString();
}, 1000);
}
ngOnInit() {
}
}
Whenever you are using the setTimeout in our code,import { setTimeout } from 'timers'
then this import we will get by autogenerating code, once remove this import statement and run the code it should work, for me working fine.
`
Do not import setTimeout from 'timers'.
It will work without any importing