From 7b723dce5482112165e90a8b2583225ffa6d0c75 Mon Sep 17 00:00:00 2001 From: Gabriel Rubens Date: Mon, 26 Sep 2016 16:02:24 -0300 Subject: [PATCH] Enhance waitDdpReady --- src/Data.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Data.js b/src/Data.js index 7691741..338f674 100644 --- a/src/Data.js +++ b/src/Data.js @@ -1,11 +1,21 @@ import ReactNative from 'react-native'; import minimongo from 'minimongo-cache'; +import Trackr from 'trackr'; +import { InteractionManager } from 'react-native'; process.nextTick = setImmediate; const db = new minimongo(); db.debug = false; db.batchedUpdates = ReactNative.unstable_batchedUpdates; +function runAfterOtherComputations(fn){ + InteractionManager.runAfterInteractions(() => { + Trackr.afterFlush(() => { + fn(); + }); + }); +} + export default { _endpoint: null, _options: null, @@ -22,9 +32,9 @@ export default { if(this.ddp) { cb(); } else { - setTimeout(()=>{ + runAfterInteractions(()=>{ this.waitDdpReady(cb); - }, 10); + }); } },