Skip to content

Commit

Permalink
Merge pull request #135 from grsabreu/enhance-containers
Browse files Browse the repository at this point in the history
Enhance waitDdpReady for performance
  • Loading branch information
Mokto committed Sep 28, 2016
2 parents 52d8ff1 + 7b723dc commit bbfa469
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Data.js
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -22,9 +32,9 @@ export default {
if(this.ddp) {
cb();
} else {
setTimeout(()=>{
runAfterInteractions(()=>{
this.waitDdpReady(cb);
}, 10);
});
}
},

Expand Down

0 comments on commit bbfa469

Please sign in to comment.