# All files / composer/utils StoreUtils.js

12.5% Statements 1/8
0% Branches 0/2
0% Functions 0/3
12.5% Lines 1/8

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20

    8x

     // Edited from: https://gist.github.com/gaearon/886641422b06a779a328

    const observeStore = (store, predicate) => {
      let performCheck;

      return new Promise((resolve) => {
        performCheck = () => {
          if (predicate.call(null, store)) {
            resolve();
            store.removeChangeListener(performCheck);
          }
        };

        store.addChangeListener(performCheck);
        performCheck();
      });
    };

    export { observeStore };