How to use the react-native-background-timer.setInterval function in react-native-background-timer

To help you get started, we’ve selected a few react-native-background-timer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Vinylize / Yetta-App / src / components / runnerView / runnerView.js View on Github external
startCount() {
    const startedTime = Date.now();
    const maxTimeoutFactor = 10;
    const interval = 200;
    BackgroundTimer.clearTimeout(this.intervalId);
    this.intervalId = BackgroundTimer.setInterval(() => {
      const timeDiff = Date.now() - startedTime;
      this.setState({fill: 100 - timeDiff * maxTimeoutFactor / 1000});
      if (this.state.fill <= 0) {
        // when timeout
        BackgroundTimer.clearTimeout(this.intervalId);
        this.setState({receivedNewOrder: false});
        this.props.setWaitingNewOrder(true);
      }
    }, interval);
  }
github AOSSIE-Org / CarbonFootprint-Mobile / app / actions / ActivityDetectionAction.js View on Github external
function startTimer(dispatch, getState) {
    if (Platform.OS === 'android') {
        this.intervalId = BackgroundTimer.setInterval(() => {
            dispatch(setDuration(getState().activity.duration + 1));
        }, 1000);
    } else {
        // Not tested for iOS
        BackgroundTimer.start();
        setInterval(() => {
            dispatch(setDuration(getState().activity.duration + 1));
        }, 1000);
    }
}
github RocketChat / Rocket.Chat.ReactNative / app / views / JitsiMeetView.js View on Github external
onConferenceJoined = () => {
		RocketChat.updateJitsiTimeout(this.rid).catch(e => console.log(e));
		if (this.jitsiTimeout) {
			BackgroundTimer.clearInterval(this.jitsiTimeout);
		}
		this.jitsiTimeout = BackgroundTimer.setInterval(() => {
			RocketChat.updateJitsiTimeout(this.rid).catch(e => console.log(e));
		}, 10000);
	}
github thousight / react-native-draggable-switch / src / utils.ts View on Github external
export const startSessionTimer = (cb: any, interval: number) => {
  const duration = interval || backgroundDuration
  if (!cb) {
    backgroundTimerEndTime = getCurrentTimeStamp() + duration
    currentCallback = defaultCallback
  } else {
    currentCallback = cb
  }

  if (!currentCallback) {
    return
  }

  stopSessionTimer()
  BackgroundTimer.start()
  timeout = BackgroundTimer.setInterval(currentCallback, duration)
}