How to use the react-native.InteractionManager.runAfterInteractions function in react-native

To help you get started, we’ve selected a few react-native 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 vobi-io / markdown-editor / editor / src / TextToolbar.js View on Github external
selectColor = ({ color = 'default' }) => () => {
    const { activeView } = this.state
    let newColor = color

    if(activeView === VIEWS.COLOR && color === 'default') {
      newColor = 'black'
    }

    if(activeView === VIEWS.FILL && color === 'default') {
      newColor = 'transparent'
    }

    InteractionManager.runAfterInteractions(() => {
      this.emit(EVENTS.CHANGE_COLOR_STYLE,  { color: newColor, type: activeView })()
    })
    // this.setDefaultView()
  }
github MetaMask / metamask-mobile / app / components / UI / AccountList / index.js View on Github external
PreferencesController.setSelectedAddress(accountsOrdered[newIndex]);

				this.props.onAccountChange();

				InteractionManager.runAfterInteractions(async () => {
					setTimeout(() => {
						Engine.refreshTransactionHistory();
					}, 1000);
				});
			} catch (e) {
				// Restore to the previous index in case anything goes wrong
				this.mounted && this.setState({ selectedAccountIndex: previousIndex });
				Logger.error('error while trying change the selected account', e); // eslint-disable-line
			}
			InteractionManager.runAfterInteractions(() => {
				setTimeout(() => {
					Analytics.trackEvent(ANALYTICS_EVENT_OPTS.ACCOUNTS_SWITCHED_ACCOUNTS);
				}, 1000);
			});
			const orderedAccounts = this.getAccounts();
			this.mounted && this.setState({ orderedAccounts });
		});
	};
github smallpath / psnine / psnine / container / topic / CommentList.tsx View on Github external
this.setState(state, () => {
      InteractionManager.runAfterInteractions(() => {
        getTopicCommentAPI(url).then(data => {
          let thisList: any[] = []
          const thisPage = parseInt(url.match(/\?page=(\d+)/)[1], 10)
          let cb = () => { }
          if (type === 'down') {
            thisList = this.state.list.concat(data.commentList)
            this.pageArr.push(thisPage)
          } else if (type === 'up') {
            thisList = this.state.list.slice()
            thisList.unshift(...data.commentList)
            this.pageArr.unshift(thisPage)
          } else if (type === 'jump') {
            // cb = () => this.listView.scrollTo({ y: 0, animated: true });
            thisList = data.commentList
            this.pageArr = [thisPage]
          }
github cliqz-oss / browser-core / platforms / react-native / timers.es View on Github external
function timerScheduler() {
  if (!taskScheduled && nextTask - Date.now() < LONG_TIMER_THRESHOLD) {
    taskScheduled = true;
    InteractionManager.runAfterInteractions(() => {
      try {
        const tNext = nextTask - Date.now();
        if (tNext < LONG_TIMER_THRESHOLD) {
          // reset nextTask
          nextTask = Number.MAX_SAFE_INTEGER;
          const taskWasRun = longTimers.map(({ runAt, fn, args }) => {
            // calculate when this task should be run
            const runIn = Math.max(runAt - Date.now(), 1);
            if (runIn > LONG_TIMER_THRESHOLD) {
              // don't run, and set nextTask run time
              nextTask = Math.min(nextTask, runAt);
              return false;
            }
            // schedule task
            setTimeout(fn, runIn, ...args);
            return true;
github EleTeam / Shop-React-Native / app / pages / AddressCreatePage.js View on Github external
_addressCreate(){
        let {telephone, fullname, detail, area_id} = this.state;

        if (!fullname.length) {
            Toast.show('请输入收货人姓名', {position:Toast.positions.CENTER});
            return;
        }
        if (!telephone.length) {
            Toast.show('请输入收货人电话', {position:Toast.positions.CENTER});
            return;
        }

        InteractionManager.runAfterInteractions(() => {
            const {dispatch, userReducer} = this.props;
            let access_token = userReducer.user.access_token;
            dispatch(addressCreate(access_token, fullname, telephone, area_id, detail));
        });
    };
}
github JasonStu / ReactNative_Shopping / App / Components / Splash.js View on Github external
this.timer=setTimeout(() => {
      InteractionManager.runAfterInteractions(() => {
        navigator.resetTo({
          component: TabBarView,
          name: 'TabBarView'
        });
      });
    }, 2000);
  }
github ramsundark5 / stitchchat / app / containers / MessagePage.js View on Github external
componentDidMount(){
        if(this.props.currentThread){
            this.loadInitialMessages();
            InteractionManager.runAfterInteractions(() => {
                let thread = this.props.currentThread;
                ThreadDao.resetUnreadCount(thread.id);
            });
        }
    }
github smallpath / psnine / psnine / container / game / GameBattle.tsx View on Github external
}, () => {
      InteractionManager.runAfterInteractions(() => {
        getGameMapperAPI(url).then(data => {
          this.setState({
            list: data,
            isLoadingMore: false,
            isRefreshing: false
          })
        })
      })
    })
  }
github rainbow-me / rainbow / src / screens / SettingsScreenWithData.js View on Github external
handleSeedPhraseState = (seedPhrase = null) =>
    InteractionManager.runAfterInteractions(() => this.setState({ seedPhrase }))
github wangdicoder / react-native-Gank / js / containers / WebViewPage.js View on Github external
componentDidMount(){
        super.componentDidMount();
        InteractionManager.runAfterInteractions(() => {
            this.setState({
                didMount: true
            });
            this.props.actions.getStarState(this.props.rowData);
        });
    }